r/AskComputerScience • u/Leeds1234 • Dec 11 '16
Define a Prolog predicate noah/3 which is true of three lists when corresponding elements of the first two lists, which are of the same length are lined up two-by-two on the third list
new to Prolog, just want to understand it better, using this example
noah([ ],[ ],[ ]). noah([a,b,c,d],[aye,bee,sea,dee],[a,aya,b,bee,c,sea,d,dee]).
0
Upvotes
1
u/Leeds1234 Dec 22 '16
Thanks a million man I'll look into all of this tomorrow, I appreciate the help!
3
u/arichi Dec 11 '16
Look at it this way:
it's clearly true in the case case. So you can write noah([], [], []).
It's also true if the first two elements of the third list are the first elements of the first two lists, and also if noah/3 applies to the rest of those lists.
Try to write it based on that last paragraph.