项目作者: MasonProtter

项目描述 :
Provides a simple macro to make readable anonymous functions in Julia
高级语言: Julia
项目地址: git://github.com/MasonProtter/LegibleLambdas.jl.git
创建时间: 2018-10-04T20:09:04Z
项目社区:https://github.com/MasonProtter/LegibleLambdas.jl

开源协议:MIT License

下载


LegibleLambdas

Build Status

Legible Lambdas for Julia.

Installation

In julia v1.0+, type ] to enter package mode, and:

  1. 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

  1. julia> f = x -> x + 1
  2. #1 (generic function with 1 method)

with

  1. julia> using LegibleLambdas
  2. julia> g = @λ(x -> x + 1)
  3. (x -> x + 1)

This ‘just works’ inside most closures too!

  1. julia> D(f, ϵ=1e-10) = @λ(x -> (f(x+ϵ)-f(x))/ϵ)
  2. D (generic function with 2 methods)
  3. julia> D(sin)
  4. (x -> ((sin)(x + 1e-10) - (sin)(x)) / 1e-10)
  5. julia> D(sin, 0.01)
  6. (x -> ((sin)(x + 0.01) - (sin)(x)) / 0.01)

License

MIT License