Short-hand partial application example added to README.md

master
Mike Gerwitz 2014-12-02 16:43:05 -05:00
parent bb9107c8c1
commit e392d411fa
1 changed files with 8 additions and 1 deletions

View File

@ -70,11 +70,17 @@ the output included within a distribution.
### Partial Applications ### Partial Applications
Dynamic function applications using `f:apply` are partially applied if Dynamic function applications using `f:apply` are partially applied if
the number of arguments provided is less than the arity of the target the number of arguments provided is less than the arity of the target
function. function. For convenience, the `apply-gen` stylesheet will also
generate functions to perform partial application without the use of
`f:apply` for the first call, as in the first example below:
```xml ```xml
<!-- produces a new dynamic function of arity 5 - 3 = 2 --> <!-- produces a new dynamic function of arity 5 - 3 = 2 -->
<variable name="partial" <variable name="partial"
select="my:arity5( 1, 2, 3 )" />
<!-- does the same, the long way -->
<variable name="partial-long"
select="f:apply( my:arity5(), 1, 2, 3 )" /> select="f:apply( my:arity5(), 1, 2, 3 )" />
<!-- consequently, currying is supported --> <!-- consequently, currying is supported -->
@ -84,6 +90,7 @@ function.
<!-- equiv = true() --> <!-- equiv = true() -->
<variable name="equiv" <variable name="equiv"
select="$result select="$result
= f:apply( my:arity5( 1, 2, 3 ), 4, 5 )
= f:apply( my:arity5(), 1, 2, 3, 4, 5 ) = f:apply( my:arity5(), 1, 2, 3, 4, 5 )
= my:arity5( 1, 2, 3, 4, 5 )" /> = my:arity5( 1, 2, 3, 4, 5 )" />
``` ```