LegibleLambas.jl is a package for making anonymous functions whose names are their expressions, ie.
julia> f = @λ(x -> x + 1)
(x -> x + 1)
julia> f(1.0)
2.0
The primary use-case I see for this functionality is for functions which return functions (closures). Suppose I have a function D
which operates on a function and gives it’s (finite difference) derivative, I can use LegibleLambdas
D(f, ϵ=1e-10) = @λ(x -> (f(x+ϵ)-f(x))/ϵ)
so that when a user wants to know what D(sin)
is, they are shown
julia> D(sin)
(x -> (sin(x + 1e-10) - sin(x)) / 1e-10)
instead of something like
julia> D(sin)
#1 (generic function with 1 method)