The question is:
When we press the key in mem ([1,2,3,4,5] ]).
We will get the output as Bile:
weird = 3
also = 2
My coding is not like this but MER (X, [xm | L]) MEM (X, [element | L]): - MEM ([GIN ([x | H], L1, L2): - Write (even (X, L]).
Count ([], L, L).
% 2 = 0, nl, write (weird), x% 2> = 1, NL, Count ([H], [X | L1], L2).Thank you for your help.
The processes you write are two separate C does things and does not really come together. mem / 2
is usually equal to builtin member / 2
, except that there is an error in your definition: In the second block, element
is an atom instead of one variable so it will not match the other elements of the list. General definition
member (x, [x | ]. Member (X, [_ | L]): - Member (X, L)
Keep in mind that this definition can not be checked only if If a word is an element of a list, but it can also be used to prepare the list.
To do this, in exactly what you are trying to do in Count / 3
: Divide the list into two lists, which includes the odd and the second one; Or weird and also calculate the number of elements? Something like sharing can be done:
count ([], [], []). Count ([x | l], hey, e): - x rim2 = / = 0, count (l, [x | o], e). Count ([x | l], hey, e): - x rim 2 =: = 0, count (l, o, [x | E]). = / = / 2
and =: = / 2
while assessing the force of arguments as arithmetic expression, = / 2
unify your arguments Tries to do The calculation and similarities of the number of obstacles can be equally, and are left as an exercise for the reader. : -)
Comments
Post a Comment