DelayedEvaluation.DelayedEvaluation
— ModuleThis module extends the idea behind Base.Fix1
and Base.Fix2
to any function and a simple indexing syntax, similar to array indexing, to create delayed evaluation function objects. This package relies on type piracy, defining Base.getindex
for Base.Callable
.
Examples:
`sin[1.0]() == sin(1.0)`
`map[!,[1,2,3]](x->x+1) == map(x->x+1,[1,2,3])`
`map[!][[1,2,3]]() == map(x->x+1,[1,2,3])`
`sort[by=x->x[1]]([(2,:a),(1,:b)]) == sort([(2,:a),(1,:b)];by=x->x[1])`
DelayedEvaluation.DelayEval
— TypeDelayEval{F,T}(f,x,kw)
returns an object for the delayed evaluation of f
with variables x
and keyword args kw
. The syntax for building such an object is f[x1,x2,...,xn,k1=v1,k2=v2,...,km=vm]
, i.e., indexing a function with the fixed arguments and keyword arguments. Like an array, using !
will leave a blank for extra arguments to be supplied on call.
Examples:
`sin[1.0]() == sin(1.0)`
`map[!,[1,2,3]](x->x+1) == map(x->x+1,[1,2,3])`
`map[!][[1,2,3]]() == map(x->x+1,[1,2,3])`
`sort[by=x->x[1]]([(2,:a),(1,:b)]) == sort([(2,:a),(1,:b)];by=x->x[1])`
DelayedEvaluation.FillPlaceHolder
— TypeFillPlaceHolder
is an iterator to supply call arguments for a DelayEval function in the positions where its fixed args are !
or as extra trainling arguments.
Example: (ReplaceColon((:a,!,!,:d),(:b,:c,:e))...,) == (:a,:b,:c,:d,:e)
Base.getindex
— Methodgetindex(f::F,x...,kw...) where {F<:Base.Callable} -> DelayEval(f,x,kw)
Build a DelayEval
object for function f
. See DelayEval
.
Examples:
`sin[1.0]() == sin(1.0)`
`map[!,[1,2,3]](x->x+1) == map(x->x+1,[1,2,3])`
`map[!][[1,2,3]]() == map(x->x+1,[1,2,3])`
`sort[by=x->x[1]]([(2,:a),(1,:b)]) == sort([(2,:a),(1,:b)];by=x->x[1])`