[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: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Wed, 9 Jan 2002 04:58:13 -0800 (PST)
 RE: mapping (Was: Re: Re: . in for)
> > but this organisation doesn't make it particularly easy to pipe
> > functions together (or at least not in a similar way to location
> > paths).
> 
> I'm sure David C or Dimitre could extend this to a piped form?
> Guessing,
>   select='map (fnA(), (map (fnb(), $departments)))'
> 
> which maps function A over the result set of mapping function b
> over $departments?

In my earlier message "Higher-order function support as means to reduce the
"standard" operators/functions":

http://sources.redhat.com/ml/xsl-list/2002-01/msg00199.html

it was shown how one could write the map function from scratch if XPath supported
higher-order functions.

 map     ::  [a] -> [a]
 map f    =  foldl ((:).f ) [ ]

The piping mentioned above is implemented by another function -- multiMap:

 multiMap :: [a] -> [a -> a] -> [a]
 multiMap xs fs  = foldr map xs fs


It is ***so easy*** to express new functions in a language which has higher-order
functions!

And the piping above will be expressed as:

   select='multiMap ($departments,
                      (fnA(), fnb(), ... , fnX())
                     )'


In another message it was also shown how to optimise a long 'piping' of maps into a
single map:

        (map f1)
  <<.>> (map f2)
 ............               
  <<.>> (map fN)   $sequence


is equal to:

map (f1 <<.>> f2 ...  <<.>> fN) $sequence

where <<.>> is the functional composition operator.

Certainly, multiMap can be modified to take advantage of this optimisation.

> 
> Like this more and more!

It is easy to fall in love with FP.

Cheers,
Dimitre Novatchev.




__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.