On 4/9/07, Robert Dodier <robert.dodier at gmail.com> wrote:
> I guess that makes create_list redundant with cartesian_product
> or maybe outermap in the multiple argument case (not map).
Not quite.
create_list( [i,j],i,[i1,i2],j,[j1,j2]) => [ [i1,j1], ...
cartesian_product({i1,i2},{j1,j2}) => { [i1,j1], ...
create_list(f(i,j),i,[i1,i2],j,[j1,j2]) => [ f( i1,j1 ), ...
map(f,cartesian_product({i1,i2},{j1,j2}))=> { f([i1,j1]), ...
(note sets and list argument)
outermap(f,[i1,i2],[j1,j2]) => [[ f( i1,j1 ), ...
(note nesting)
> But now I'm wondering --- is makelist w/ multiple arguments
> supposed to be like map or like cartesian_product or outermap?
> Or something else?
They all seem useful. It would, on the other hand, be nice if we had a
systematic approach to all this using fewer primitives which would combine
nicely, or at least had systematic names.
Example:
map_cartesian == map( fapply(f), cartesian_product(...) )
where fapply converts a function of N arguments to a function of a *list of*
N arguments:
fapply(f):=
buildq( [f, args:?gensym()], lambda([[args]],apply(f,args))
(buildq and gensym needed because we don't have lexical scoping :-( )
-s