xsl-list
[Top] [All Lists]

Re: How do I get a SUM of the string-length of all child nodes ??

2005-05-28 21:25:54
Thank you Dimitre for explanation ;) I am obliged ..

Regards,
Mukul

--- Dimitre Novatchev <dnovatchev(_at_)gmail(_dot_)com> 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.


--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--