Giter VIP home page Giter VIP logo

apipe.jl's Introduction

APipe.jl

Build Status codecov

Lets you abuse |> and may make you |> addict.

Examples

With @> macro, you no longer need to write the boring val |> x -> λ(x, val2)

  • compatible with usual |> operations
julia> λ(val) == val |> λ == @> val |> λ
  • given function call, injects chained value into the first argument (no need to write val |> x -> λ(x, val2))
julia> val |> x -> λ(x) == @> val |> λ()
julia> val |> x -> λ(x, val2) == @> val |> λ(val2)
julia> val |> x -> λ(x, val2) |> x -> λ2(x, val3) == @> val |> λ(val2) |> λ2(val3)
  • using tuple, the argument position can be specified
julia> val |> x -> λ(x) == @> val |> (1, λ())
julia> val |> x -> λ(val2, x) == @> val |> (2, λ(val2))
julia> val |> x -> λ(val2, x) |> x -> λ2(x, val3) == @> val |> (2, λ(val2)) |> λ2(val3)
  • keyword argument should be specified with symbol
julia> val |> x -> λ(val2; keyword = x) == @> val |> (:keyword, λ(val2))
julia> val |> x -> λ(val2; keyword = x) |> x -> λ2(val3; keyword2 = x) == @> val |> (:keyword, λ(val2)) |> (:keyword2, λ2(val3))
julia> (ary .|> string .|> x -> λ(x, val)) == @> ary .|> string .|> λ(val)

With @>> macro, you no longer need even |> operators themselves.

Equivalent to the examples of @>

julia> λ(val) == val |> λ == @>> val λ
julia> val |> x -> λ(x) == @>> val λ()
julia> val |> x -> λ(x, val2) == @>> val λ(val2)
julia> val |> x -> λ(x, val2) |> x -> λ2(x, val3) == @>> val λ(val2) λ2(val3)
julia> val |> x -> λ(x) == @>> val (1, λ())
julia> val |> x -> λ(val2, x) == @>> val (2, λ(val2))
julia> val |> x -> λ(val2, x) |> x -> λ2(x, val3) == @>> val (2, λ(val2)) λ2(val3)
julia> val |> x -> λ(val2; keyword = x) == @>> val (:keyword, λ(val2))
julia> val |> x -> λ(val2; keyword = x) |> x -> λ2(val3; keyword2 = x) == @>> val (:keyword, λ(val2)) (:keyword2, λ2(val3))

With @.>> macro, all the implicit |> operations are dot-fused.

Equivalent to the last example of @>

julia> (ary .|> string .|> x -> λ(val, x)) == @.>> ary string (2, λ(val))

Random TODOs

  • support .|> fusing
  • update documents

License

MIT License.

Author

  • KADOWAKI, Shuhei - Undergraduate@Kyoto Univ. - aviatesk

apipe.jl's People

Contributors

aviatesk avatar

Watchers

 avatar  avatar

apipe.jl's Issues

Add vs normal code in julia

With the current examples I don't know what apipipe is doing? Need to show normal julia code for a comparison

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.