take :: Int -] [a] -] [a]
take 0 _ = []
take _ [] = []
take n (x:xs) | n]0 = x : take (n-1) xs
take _ _ = error "Prelude.take: negative argument"
XSL
[xsl:stylesheet version = "1.0" exclude-result-prefixes = "xsl msxsl"
xmlns:xsl="http://www.w3.org/1999/XSL/T
xmlns:msxsl="urn:schemas-microsoft-com:x
[xsl:template name = "buildListWhile" ]
[xsl:param name = "pGenerator" select = "/.." /]
[xsl:param name = "pParamGenerator" select = "/.." /]
[xsl:param name = "pController" select = "/.." /]
[xsl:param name = "pParam0" select = "/.." /]
[xsl:param name = "pContollerParam" select = "/.." /]
[xsl:param name = "pElementName" select = "'el'" /]
[xsl:param name = "pList" select = "/.." /]
[xsl:if test = "not($pController)" ]
[xsl:message terminate = "yes" ]
[buildListWhile]Error: No pController specified:
would cause infinite processing.
[/xsl:message]
[/xsl:if]
[xsl:variable name = "vElement" ]
[xsl:element name = "{$pElementName}" ]
[xsl:apply-templates select = "$pGenerator" ]
[xsl:with-param name = "pParams" select = "$pParam0" /]
[xsl:with-param name = "pParamGenerator" select = "$pParamGenerator" /]
[xsl:with-param name = "pList" select = "$pList" /]
[/xsl:apply-templates]
[/xsl:element]
[/xsl:variable]
[xsl:variable name = "newList" ]
[xsl:copy-of select = "$pList" /]
[xsl:copy-of select = "msxsl:node-set($vElement)/*" /]
[/xsl:variable]
[xsl:variable name = "vResultList"
select = "msxsl:node-set($newList)/*" /]
[xsl:variable name = "vAccept" ]
[xsl:apply-templates select = "$pController" ]
[xsl:with-param name = "pList"
select = "$vResultList" /]
[xsl:with-param name = "pParams"
select = "$pContollerParam" /]
[/xsl:apply-templates]
[/xsl:variable]
[xsl:choose]
[xsl:when test = "not(string($vAccept))" ]
[xsl:copy-of select = "$pList" /]
[/xsl:when]
[xsl:otherwise]
[xsl:call-template name = "buildListWhile" ]
[xsl:with-param name = "pGenerator"
select = "$pGenerator" /]
[xsl:with-param name = "pParamGenerator"
select = "$pParamGenerator" /]
[xsl:with-param name = "pController"
select = "$pController" /]
[xsl:with-param name = "pContollerParam"
select = "$pContollerParam" /]
[xsl:with-param name = "pParam0"
select = "$pParam0" /]
[xsl:with-param name = "pElementName"
select = "$pElementName" /]
[xsl:with-param name = "pList"
select = "$vResultList" /]
[/xsl:call-template]
[/xsl:otherwise]
[/xsl:choose]
[/xsl:template]
[/xsl:stylesheet]