0
votes

If we have a list with sublist, how do we get a specific element in that sublist?

Example: [[a,b,c],[d,e,f],[g,h,i],[j,k,l]].

We want to fetch i.

1

1 Answers

0
votes

fetch just remember assembly language to me. Then I can't make sense of your question, that I would tackle in this way

?- member(X, [[a,b,c],[d,e,f],[g,h,i],[j,k,l]]), member(i, X).

If elements in sublists would carry values, then that could make sense

?- member(X, [[a-1,b-3,c-88],[d-1,e-2,f-0],[g-1,h-1,i-2],[j-2,k-1,l-3]]), member(i-N, X).
X = [g-1, h-1, i-2],
N = 2 ;
false.