length/2 is often used to generate list of variables of a given size, e.g.
?- length(L,5).
L = [_, _, _, _, _].
Normally when a list of variables is displayed, if the variable is not bound to a value it is displayed as _ but the variables really are different variables, e.g.
?- length(L,5),numbervars(L).
L = [A, B, C, D, E].
Now to get the desired result (list of values) the value just needs to be bound to each variable. maplist/3 should come to mind.
maplist/3 is often written using a helper predicate for the goal but using library(yall) a Lambda can be used, e.g.
maplist([_,0]>>true,L0,L).
However if one tries to use a variable for the value, e.g.
maplist([_,Value]>>true,L0,L).
it will not work as expected.
With library(yall) one has to be careful with the variables used in the Lambda. Under the coves library(yall) (src) makes use of copy_term_nat/2 but library(yall) also provides a means to resolve the problem.
A bracy list {...} specifies which variables are shared between the wrapped goal and the surrounding context.
Thus Value can be shared outside of the Lambda and inside the Lambda when identified in the bracy list, i.e. {Value}, e.g.
It took me a long time to realize that it is possible to pass arguments to the goal in maplist (as you do with =(Value) in your solution, and I have some difficulties deciphering how this works more exactly from the documentation here. Are there other parts of the docs that cover this more in detail?
EDIT:
For those interested there is more info about this on this page, which is linked to in the docs.
There is a whole array of examples attached to maplist/2, right there under the docs. Several of them show how to use maplist with what I think is called partial application? “Filling” a list is there among the examples, too. You just need to click on the descriptive title of the example to expand it.