From ra27946@scs.ubbcluj.ro  Fri Dec 15 08:48:45 2000
Received: from Proxy2.UBBCluj.Ro (IDENT:root@Mail-Exchange.UBBCluj.ro [193.230.247.198])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id IAA07168
	for <prolog@swi.psy.uva.nl>; Fri, 15 Dec 2000 08:48:42 +0100 (MET)
Received: from Zeus.UBBCluj.Ro (IDENT:root@Zeus.UBBCluj.Ro [193.231.20.1])
	by Proxy2.UBBCluj.Ro (8.9.3/8.9.3) with ESMTP id JAA11479;
	Fri, 15 Dec 2000 09:49:27 +0200
Received: from Home.SCS.UBBCluj.Ro (IDENT:root@home.scs.ubbcluj.ro [193.231.20.38])
	by Zeus.UBBCluj.Ro (8.9.3/8.9.3) with ESMTP id JAA28771;
	Fri, 15 Dec 2000 09:48:15 +0200
Received: from Rave.SCS.UBBCluj.Ro (IDENT:ra27946@Rave.SCS.UBBCluj.Ro [193.231.20.39])
	by Home.SCS.UBBCluj.Ro (8.11.0/8.11.0) with ESMTP id eBF7m9b01243;
	Fri, 15 Dec 2000 09:48:11 +0200
Date: Fri, 15 Dec 2000 09:48:08 +0200 (EET)
From: Rastei Amelia Viorela <ra27946@scs.ubbcluj.ro>
To: "Richard A. O'Keefe" <ok@atlas.otago.ac.nz>
cc: prolog@swi.psy.uva.nl
Subject: Re:  [SWIPL] About Applying a predicate to all the elements of a
 list
In-Reply-To: <200012150105.OAA25849@atlas.otago.ac.nz>
Message-ID: <Pine.LNX.4.21.0012150945290.28222-100000@Rave.SCS.UBBCluj.Ro>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII





     I thank Richard O'Keefe and Nicos and Jan and Dmitry for
all their useful information.
     It really helps me.

     Best regards,

     Amelia.




On Fri, 15 Dec 2000, Richard A. O'Keefe wrote:

> Rastei Amelia Viorela <ra27946@scs.ubbcluj.ro> wrote:
> > Sorry, previous question was not clear at all!
> > I reformulate:
> > How does maplist actually work? 
> 	
> You don't need to know that.
> What you need to know is what it *means*.
> 
> The maplist/N family of predicates, designed by Lawrence Byrd and me,
> can be explained as
> 
>     maplist(P, [X11,...,X1n], ..., [Xm1,...,Xmn]) :-
> 	P(X11, ..., Xm1),
> 	...
> 	P(Xm1, ..., Xmn).
> 
> For the sake of argument, let's invent an :- index declaration, which
> says to build indices on each of the specified arguments independently,
> and to use the first one in numerical order for which the actual argument
> is non-variable.  Then we'd have
> 
>     :- index maplist(_,1).
> 
>     maplist(P, []).
>     maplist(P, [X1|X1s]) :-
>         call(P, X1),
>         maplist(P, X1s).
> 
>     :- index maplist(_,1,2).
> 
>     maplist(P, [], []).
>     maplist(P, [X1|X1s], [X2|X2s]) :-
>         call(P, X1, X2),
>         maplist(P, X1s, X2s).
> 
>     :- index maplist(_,1,2,3).
> 
>     maplist(P, [], [], []).
>     maplist(P, [X1|X1s], [X2|X2s], [X3|X3s]) :-
>         call(P, X1, X2, X3),
>         maplist(P, X1s, X2s, X3s).
> 
> 
> As for the call/N family (invented by me and Alan Mycroft),
> it's defined *as if*
> 
>     call(P(X1,...,Xm), Y1, ..., Yn) :- P(X1, ..., Xm, Y1, ..., Yn).
> 
> There are many ways to implement that, some faster than others.
> 
> 	    I am trying to implement MINIMAX algotithm. For Tic tac Toe.
> 
> Is that the same as noughts and crosses?
> 
> The important thing is that the first argument of call/(N+1) or
> maplist/(N+1) is a callable term representing a call to a predicate
> that is missing the *last* N arguments.  (Why the last?  Because of
> the general inputs-before-outputs style rule in Prolog.)
> 

-- 

 Amelia Rastei,
 Dept. Computer Science,
 Babes Bolyai University,
 Cluj Napoca, Romania. 


