I have a problem on Prolog related to list of lists. The problem is about implementing a Prolog predicate: to_do(ListOfLists,_,Result)
.
Where ListOfLists
is a list of lists of character, either a
,b
,c
, or d
. Result must substitute a
to ai
, b
to bi
, c
to x
, and d
to y
.
For example,
?- to_do([[b,c],[a,d]],_,Result).
Result = [[bi,x],[ai,y]].
?- to_do([[a,a,b],[b,c,d],[c,c,a]],_,Result).
Result = [[ai,ai,bi],[bi,x,y],[x,x,ai]].
Note that Result must also be a list of lists.
Thanks a lot!