Hello all,
I created a small package extending the functionality of Base.Fix1
and Base.Fix2
to any function and provides a syntax analogous to array or DataFrame
indexing to fix function arguments using !
(instead of :
) as a placeholder:
https://github.com/flipgthb/DelayedEvaluation.jl
Usage examples:
getindex[!,1]([1,2,3]) == [1,2,3][1]
sin[0.0]() == sin(0.0)
mapfoldl[x->x+1,!,[1,2,3]](*) == mapfoldl(x->x+1,*,[1,2,3])
It works by creating a DelayEval <: Function
object when indexing a function. Composition and chaining also works:
getindex[!,1][[1,2,3]]() = getindex([1,2,3],1)
(first ∘ getindex[!,2])([(1,:a),(2,:b)]) == first(getindex([(1,:a),(2,:b)],2))
Is this useful? Maybe… Probably it is just dumb, but I did anyway