Subject: Re: [xsl] How do I get a SUM of the string-length of all child nodes ?? From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Sun, 29 May 2005 14:03:32 +1000 |
> 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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How do I get a SUM of the, Mukul Gandhi | Thread | Re: [xsl] How do I get a SUM of the, David Carlisle |
Fwd: [xsl] Double-spacing <para/>, David Nedrow | Date | [xsl] grouping in a separate data f, Andrew Kirkpatrick |
Month |