Re: Impressed but confused, gluing a list together...
"Michał Bieliński" <[email protected]>
| Newsgroups | gmane.comp.gnu.prolog.general |
|---|---|
| Message-ID | <[email protected]> |
Dnia 1 Października 2013, 23:50, Wt, Sean Charles napisał:
>> I added a cut to avoid the solution with trailing glue.
>> join([X], _, [X]) :- !.
>
> I am confused at the cut.. I have not yet experienced trailing glue,
> that was the point of the second rule!?
When I compiled your initial example and tested it GNU Prolog returned two
results. I wanted only one. The behavior without cut is this:
GNU Prolog 1.4.4 (32 bits)
Compiled Apr 29 2013, 20:41:58 with gcc
By Daniel Diaz
Copyright (C) 1999-2013 Daniel Diaz
| ?- join("ABC", "Z", X).
X = [97,[122],98,[122],99] ? ;
X = [97,[122],98,[122],99,[122]]
yes
With cut gprolog is satisfied with telling me the first solution.
--
Michał Bieliński