I wonder if it’s possible to do something like the following in prolog
L = [1,2,3,4,5,_,_,7].
i want to do something like
getElements(L, R)
that returns
R = [1,2,3,4,5,7]
and ignore the wildcards in the list
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your Prolog has library(apply), you can write
or, a bit more compact
Otherwise, this should be a working predicate:
edit as highlighted by @false, the latter getElements/2 is buggy, due to matching with the anonymous variable in last clause. Here a correction