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

Re: How do I get a SUM of the string-length of all chi

Subject: Re: How do I get a SUM of the string-length of all child nodes ??
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Sat, 28 May 2005 21:25:54 -0700 (PDT)
map string
Thank you Dimitre for explanation ;) I am obliged ..

Regards,
Mukul

--- Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
> >  What does map function do? 
> 
> Formal definition in Haskell prelude (Prelude.hs):
> 
>      map              :: (a -> b) -> [a] -> [b]
>      map f xs          = [ f x | x <- xs ]
> 
> 
> The first line above defines the type (signature) of
> the "map"
> function. It takes two arguments:
> 
>    -  a function of type a -> b (with domain "a" and
> codomain "b"  --
> this means that the
>       type of thie arguments is "a" and the type of
> the results is "b")
>       Because "map" has an argument, which is a
> function, "map" is a
> higher-order
>      function.
> 
>   - a list of elements each of type "a"
> 
> The type of the result is a list of elements of type
> "b".
> 
> The second line of the definition above defines
> exactly the map
> function. We see that the result of applying a
> function "map" to its
> two arguments -- a function "f" and a list "xs" -- 
> is the set of all
> "f x"  (which means f(x))  where "x" belongs to the
> list "xs"
> 
> More informally, we have a list of elements of the
> same type ("a") and
> a function "f", defined on "a" and producing results
> of type "b".
> 
> The result of applying "map" on "f" and a list "xs"
> (all of whose
> elements are of type "a") is another list  "ys" ,
> whose elements "y"
> are the results of applying "f" on the corresponding
> elements "x" of
> "xs".
> 
> 
> Example:
> 
>   map (2 * )  [1,2,3,4]  =  [2,4,6,8]
> 
> where (2 *) is a function, which produces twice its
> argument.
> 
>   map string-length ['one', "two", "three", "four"] 
> =  [3, 3, 5, 4]
> 
> then, we'll have:
> 
>   sum (map string-length ['one', "two", "three",
> "four"] ) = 15
> 
> 
> > Please explain what does
> > sum(f:map(f:string-length(), /*/node())) mean ..
> 
> Almost the same as the last line above  -- I hope it
> is clear now.
> 
> 
> Cheers,
> Dimitre Novatchev.
> 
> 


		
__________________________________ 
Do you Yahoo!? 
Make Yahoo! your home page 
http://www.yahoo.com/r/hs

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.