This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: mapping (Was: Re: Re: . in for)
- From: naha at ai dot mit dot edu
- To: Joerg Pietschmann <joerg dot pietschmann at zkb dot ch>
- Cc: XSL List <xsl-list at lists dot mulberrytech dot com>
- Date: Fri, 11 Jan 2002 13:34:43 -0500 (EST)
- Subject: Re: mapping (Was: Re: [xsl] Re: . in for)
- References: <3C3EEE72.3CB7790B@zkb.ch>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Quoting Joerg Pietschmann <joerg.pietschmann@zkb.ch>:
[...]
> When discussing operators which take multiple sequences as operands,
> one has to decide whether the lambda iterates over the sequences
> in parallel (as the various map* functions in LISP do) or whether
> it iterates over the cartesian product (as DB table joins to).
> Having similar syntax for both can be confusing.
> BTW expressing a join in LISP with established functionality
> would probably look like
> (defun map-join (expr seq1 seq2)
> (mapcar '(lambda (arg1)
> (mapcar '(lambda (arg2) (funcall expr arg1 arg2))
> seq2)
> seq1))
> Can one of the experts confirm this? It's been a while since i
> was active...
Almost. (map-join '+ '(1 2 3) '(10 20))
would give you
((11 21) (12 22) (13 23))
which probably has one more level of nesting than you'd expect for
a join operation. To achieve that, you'd need to replace the outermost
MAPCAR in MAP-JOIN with the sibling of MAPCAR that combines using
APPEND or NCONC rather than CONS. I'll not take the trouble to look it
up right now.
[...]
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list