Guest User

Untitled

a guest
Aug 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. Prolog how to store first 3 elements in a list into another list
  2. first_three(N,[H|T],[H|_]):- not(N=0),N is N-1, first_three(N,T,L).
  3.  
  4. first_three(0,_,[).
  5. first_three(N,[H|T],[H|L]):-
  6. N=0,
  7. N1 is N-1,
  8. first_three(N,T,L).
  9.  
  10. first_three([One,Two, Three|_], [One,Two, Three]).
  11.  
  12. first_three(Path, Y).
Add Comment
Please, Sign In to add comment