xsl-list
[Top] [All Lists]

Re: [xsl] ANN: How to Create XSLT Functions that Manipulate Functions

2010-09-25 14:03:52
Seems OK as an introduction, however:

1. The function map() is traditionally defined in almost all FP
languages to take as first argument a function that operates on a
*single item* of the sequence -- not on all items.

Therefore, either do not use the name "map" -- to avoid the confusion
with the esatblished meaning of map(), or re-define it:


    <xsl:function name="f:map" as="item()*">
      <xsl:param name="pFun" as="element()"/>
      <xsl:param name="pList1" as="item()*"/>

      <xsl:sequence select=
       "for $this in $pList1 return
          f:apply($pFun, $this)"
      />
    </xsl:function>


2. It is useful to define the function f:apply() --witha at least the
one-argument overload version:

  <xsl:function name="f:apply">
   <xsl:param name="pFunc" as="element()"/>
   <xsl:param name="arg1"/>

    <xsl:apply-templates select="$pFunc" mode="f:FXSL">
      <xsl:with-param name="arg1" select="$arg1"/>
    </xsl:apply-templates>
  </xsl:function>


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play



On Sat, Sep 25, 2010 at 11:37 AM, Costello, Roger L. 
<costello(_at_)mitre(_dot_)org> wrote:

Hi Folks,

I wrote a short article that shows, step by step, how to create XSLT 
functions that manipulate functions (i.e., how to create higher-order 
functions):


Introduction

A powerful programming technique is to create functions that can accept 
functions as arguments or return functions as values. Functions that 
manipulate functions are called higher-order functions. This article shows 
how to implement higher-order functions using XSLT 2.0.

More ...

http://www.xfront.com/higher-order-functions-in-XSLT/How-to-Create-XSLT-Functions-that-Manipulate-Functions.pdf

/Roger

--~------------------------------------------------------------------
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>
--~--


--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>