|
Subject: Re: [xsl] 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) |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] How do I get a SUM of the, Michael Kay | Thread | [xsl] Differences between AWTRender, senetex |
| [xsl] grouping in a separate data f, Andrew Kirkpatrick | Date | [xsl] sum function, Andreas Schnabl |
| Month |