Hello all! I really need some help of yours
I've got all these rules:
Returns all the vowels on a list
Flattens a list:
Returns true or false:
How can I type
And get as result this
?
How can I join the rule
with the
?
And how can I create a rule that is able to remove the duplicates ?
PS: I can't use any of the built-in predicates
I've got all these rules:
Returns all the vowels on a list
Code:
extractvowels([], []).
extractvowels([H|T], R) :- consonant(H), extractvowels(T, R).
extractvowels([H|T],[H|R]) :- \+ consonant(H), extractvowels(T, R).
Flattens a list:
Code:
flatten([],[]).
flatten([A|L],[A|L1]) :- xatom(A), flatten(L,L1).
flatten([A|L],R) :- flatten(A,A1), flatten(L,L1), append(A1,L1,R).
xatom(A) :- atom(A).
xatom(A) :- number(A).
Returns true or false:
Code:
member(X, [X|_]).
member(X, [_|Tail]) :- member(X, Tail).
How can I type
Code:
extractvowels([s,a,r,a],X).
Code:
X = [a].
How can I join the rule
Code:
flatten
Code:
extractvalues
And how can I create a rule that is able to remove the duplicates ?
PS: I can't use any of the built-in predicates