What im trying to do is:
fromHistory/2
fromHistory(HL,FL)
FL is the 3rd element of the list if the list contains the word "ate"
FL is the 4th element of the list if the list contains all the words ["you","can","have"]
The predicate is supposed to loop on a list of lists HL and if one of the lists inside contains the words above, it should append the 3rd/4th element depending on the word found to FL, else it shouldn't get anything.
?- fromHistory([[i,ate,x], [you,can,have,y]], FL).
FL = [x, y] ;
false.
?- fromHistory([[this,is,a,useless,input], [i,ate,x], [another,input],
[another,useless,input], ["Ok"], [you,can,have,y]], FL).
FL = [x, y] ;
false.
x and y are not always at the end of the list but are the strings after ["ate"] and ["you","can","have"]
my attempt using the find version in here
find(X,Y,[X,Y|Tail]):-
!.
find(X,Y,[_|Tail]):-
find(X,Y,Tail).
foodFromHistory(HL1, FL):-
flatten(HL1, HL),
find(ate, FL1, HL),
find([you, can, have], FL2, HL),
FL = [FL1|FL2].
However it doesnt work with [you,can,have] and returns false, it also doesn't work on the entire list but rather on the first occurrence only.