This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mapping (Was: Re: Re: . in for)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]