Skip to content

felippe-alves/DelayedEvaluation.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DelayedEvaluation

Build Status

DelayedEvaluation

This package extends the functionality of Base.Fix1 and Base.Fix2 to any function and provide a syntax to build DelayEval objects via delay for callable objects.

Usage

Use the function delay with : as a placeholders where arguments will be supplied on call. Examples:

delay(sin,1.0)() == sin(1.0)

delay(map,:,[1,2,3])(x->x+1) = map(x->x+1,[1,2,3])

delay(mapfoldl,x->x+1,:,[1,2,3])(*) == mapfoldl(x->x+1,*,[1,2,3])

Keyword arguments are also supported

delay(sort; by=x->x[1])([(2,:a),(1,:b)]) == sort([(2,:a),(1,:b)]; by=x->x[1])

delay(sort; by=x->x[1])([(2,:a),(1,:b)]; by=x->x[2]) == sort([(2,:a),(1,:b)]; by=x->x[2])

DelayEval <: Function, so composition also works

(first  delay(getindex,:,2))([(1,:a),(2,:b)]) == first(getindex([(1,:a),(2,:b)],2))

and also indexing a DelayEval will create a new one

delay(delay(getindex,:,2),[(1,:a),(2,:b)])() == getindex([(1,:a),(2,:b)],2)

Broadcasting returns a container of DelayEvals:

   delay.(sin,[0.0,1.0]) == [delay(sin,0.0), delay(sin,1.0)]

Packages with similar functionality

FixArgs.jl ChainedFixes.jl

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages