[ANN] LambdaFn.jl

Hi all,

I have created the following, very small, package: LambdaFn.jl. It’s for creating anonymous functions in a way I find to be handy.

It’s best explained by example:

using LambdaFn

@λ(_ + _) # == (x,y) -> x+y
@λ(_a*_b + _a) # == (a,b) -> a*b + a
@λ(_2 - _1) # == (_1,_2) -> _2 - _1
@λ(_1 - _3) # == (_1,_2,_3) -> _1 - _3
filter(@λ(_.value > 10),data) # == filter(x -> x.value > 10,data)
1:10 |> @λ(filter(@λ(_ > 3),_)) == 4:10   

Very similar in spirit to this PR, but it’s a little different. I welcome any feedback.

21 Likes

I like it! I have alwasy found (x,y)->h(f(x)+g(y)) to be cumbersome! You can type λ with \lambda

Thanks for doing this! Experimenting with this syntax in a package is the perfect way to explore it.