https://github.com/masonprotter/legiblelambdas.jl
Provides a simple macro to make readable anonymous functions in Julia
https://github.com/masonprotter/legiblelambdas.jl
anonymous-functions julia macros
Last synced: 28 days ago
JSON representation
Provides a simple macro to make readable anonymous functions in Julia
- Host: GitHub
- URL: https://github.com/masonprotter/legiblelambdas.jl
- Owner: MasonProtter
- License: mit
- Created: 2018-10-04T20:09:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-09T23:34:44.000Z (over 4 years ago)
- Last Synced: 2024-10-19T17:46:40.411Z (7 months ago)
- Topics: anonymous-functions, julia, macros
- Language: Julia
- Size: 39.1 KB
- Stars: 29
- Watchers: 5
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LegibleLambdas
[](https://travis-ci.com/MasonProtter/LegibleLambdas.jl)
Legible Lambdas for Julia.
## Installation
In julia **v1.0+**, type `]` to enter package mode, and:
```
pkg> add LegibleLambdas
```## Introduction
LegibleLambdas.jl provides a macro `@λ` (and an alias `@lambda`) for
defining a type of anonymous function which is printed in a nicer form
than the relatively uninformative gensyms of traditional anonymous
functions.Compare the printing of
```julia
julia> f = x -> x + 1
#1 (generic function with 1 method)
```
with
```julia
julia> using LegibleLambdasjulia> g = @λ(x -> x + 1)
(x -> x + 1)
```This 'just works' inside most closures too!
```julia
julia> D(f, ϵ=1e-10) = @λ(x -> (f(x+ϵ)-f(x))/ϵ)
D (generic function with 2 methods)julia> D(sin)
(x -> ((sin)(x + 1e-10) - (sin)(x)) / 1e-10)julia> D(sin, 0.01)
(x -> ((sin)(x + 0.01) - (sin)(x)) / 0.01)
```## License
MIT License