Subject: RE: Esoteric XSLT/FXSL question
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 28 May 2008 21:30:29 +0100
|
> Now, the FP alphabet of functions includes as its signature
> functions, "map", "fold" (aka "reduce") and so on.
>
> However "so on" rarely includes "foreach" as a signature
> function of the FP idiom. Is this because "foreach" implies
> some kind of time ordered calculation, and therefore not optimizable?
xsl:for-each is essentially a map() or apply() function. More specifically
<xsl:for-each select="S">
<instructions/>
</xsl:for-each>
is equivalent to the higher-order function call map(S, instructions) where
"instructions" is interpreted as a function applied to the context node.
The use of the English words "for each" is a mixed blessing. On the one
hand, it makes your typical user less uncomfortable than if it were named
xsl:map. On the other hand, it gives people the wrong impression that it is
procedural.
Michael Kay
http://www.saxonica.com/
|