Re: Ann: SWI-Prolog 7.1.0

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 11/27/2013 06:25 AM, Richard A. O'Keefe wrote:
> No, the special role does NOT depend on whether or not there
> are additional arguments.  The first element of the list is
> ALWAYS the function symbol and the number of remaining elements
> is ALWAYS the arity and X =.. [X] for EVERY term X that is neither
> a variable nor a compound term.

You are just moving the additional tests elsewhere: into functor/3.
I agree that =../2 and functor/3 are designed to form a good combo.
I'll quote your "Univ is admittedly a relic of the pre-Cambrian.".
Joining these two conclusion, I think we should conclude that
functor/3 is also a relic.

Changing these relics breaks too much (I tried).  That is why
I've defined a new pair of predicates.  I assume they will
just co-exist.  In theory, it should be possible that at some
point we deprecate functor/3 and =../2.

	Cheers --- Jan

> The only thing that is special is that numbers cannot be the
> function symbols of compound terms, but that has nothing to do
> with univ.  You can implement the traditional univ as
>
> 	=..(Term, [Function|Arguments]) :-
> 	    (   nonvar(Term) ->
> 		functor(Term, Function, Arity),
> 		length(Arguments, Arity)
> 	    ;   length(Arguments, Arity),
> 	        functor(Term, Function, Arity)
> 	    ),
> 	    '=.. arguments'(Arguments, 0, Term).
>
> 	'=.. arguments'([], _, _).
> 	'=.. arguments'([Arg|Args], N0, Term) :-
> 	    N1 is N0 + 1,
> 	    arg(N1, Term, Arg),
> 	    '=.. arguments'(Args, N1, Term).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.