I've got a list consisting of smaller lists inside of it, each list consisting of 2 items:
[[a,1],[b,2],[c,3]]
I'm using a function called take(1,L,R) to take the first item from list L and return the item R. The code for the take function is here:
take(0,X,X).
take(N,[H|T],[H|R]):-
N>0, M is N-1,
take(M,T,R).
At the moment a run may look like this:
1 ?- take(1,[[a],[b],[c]],Taken).
Taken = [[a], [b], [c]]
Which is the same as the input! This is the same for a "regular" 1-level-depth list:
2 ?- take(1,[a,b,c],Taken).
Taken = [a, b, c]
Question:
The question for you is how can I make the result look like:
1 ?- take(1,[[a],[b],[c]],Taken).
Taken = [a]
I want to return the first N items of the list I send it.