Self-test 3 Solutions
|
Introductory list processing | ||
| ?- dissect_list([]). [] yes
| ?- dissect_list([Head|[b, c]]). _70 b c [] true ? ; no | ?- dissect_list([1, car(metro, green)]). 1 car(metro,green) [] yes | ?- dissect_list([[a,l,p,h,a], [b,e,t,a]]). [a,l,p,h,a] [b,e,t,a] [] yesNote that the argument here is a list of two elements, both of which are lists. | ?- dissect_list([Tl|Hd]). _66 [] Hd = [] ? ; {This is the variable instantiation} _180 {This is the next alternative} [] Hd = [_A] ? ; {This is the variable instantiation} _196 {This is the next alternative} [] Hd = [_A,_B] ? ; {This is the variable instantiation} _212 {This is the next alternative} [] Hd = [_A,_B,_C] ? {This is the variable instantiation} yes |
||