[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: mapping (Was: Re: Re: . in for)
From: naha@xxxxxxxxxx
Date: Fri, 11 Jan 2002 13:34:43 -0500 (EST)
cartesian product lisp mapcar
Quoting Joerg Pietschmann <joerg.pietschmann@xxxxxx>:

> 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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.