is it possible to get all elements from list of lists in Prolog?
Something like: We have getElements([[[a,b,[c]],d,e],f,g,[h,[i,j]]],S) and the result is: S = [a,b,c,d,e,f,g,h,i,j] …
Thanks for help.
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.
In SWI-Prolog (and maybe others), you can use
flatten/2:Note that the SWI-Prolog manual page for
flatten/2includes the following statement:However, the page doesn’t say whether there is another native predicate to replace it.
I’m sure a better answer will be supplied.