Re: Help with PROLOG predicates
From: Martin Sondergaard (nobody_at_nowhere.com)
Date: 12/03/03
- Previous message: Brian: "Re: draw icon"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 3 Dec 2003 18:24:06 -0000
> 2) even_length/1. Succeeds (true) if the list given by
the
> parameter has even number of elements. Do not use arithmetic.
>
> Examples:
>
> 34 ?- even_length([a, b, c]).
>
> No
>
> 35 ?- even_length([a, b, c, c]).
>
> Yes
>
> 36 ?- even_length([]).
>
> Yes
>
Here is a hint for that problem.
The solution is something like this ...
even_length( ... ) :- ...
even_length([_, _]).
even_length( ... ) :-
-- Martin Sondergaard.
- Previous message: Brian: "Re: draw icon"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]