Hi,
I am prolog newbie and I really need some help.
Given a nested list like [[a,1], [b,2], [c,3]], I need to create a new list containing all the letters (ex:[a,b,c]). I am having a very hard time with this. The following is what I have so far.
%main function
%getLettList(+InputList, -ListOfLetters).
getLettList([]|_).
getLettList([H|T],List) :-
putLett(H,List),
getLettList(T,List).
%putLett(+List, -ListOfLetters).
%putLett extracts the first element
%from the List and places it in
%ListOfLetters.
putLett([Lett|Tail], [Lett|List]).
When I compile, I get a warning: "Singleton variables: [Tail,List]"
When I run the prog, with the input getLettList([[a,1],[b,2],[c,3]],[]).
I get no as an output.
Kindly help.
I am prolog newbie and I really need some help.
Given a nested list like [[a,1], [b,2], [c,3]], I need to create a new list containing all the letters (ex:[a,b,c]). I am having a very hard time with this. The following is what I have so far.
%main function
%getLettList(+InputList, -ListOfLetters).
getLettList([]|_).
getLettList([H|T],List) :-
putLett(H,List),
getLettList(T,List).
%putLett(+List, -ListOfLetters).
%putLett extracts the first element
%from the List and places it in
%ListOfLetters.
putLett([Lett|Tail], [Lett|List]).
When I compile, I get a warning: "Singleton variables: [Tail,List]"
When I run the prog, with the input getLettList([[a,1],[b,2],[c,3]],[]).
I get no as an output.
Kindly help.