https://github.com/Ismael-VC/InfixFunctions.jl
Julia infix function hack.
https://github.com/Ismael-VC/InfixFunctions.jl
Last synced: 11 months ago
JSON representation
Julia infix function hack.
- Host: GitHub
- URL: https://github.com/Ismael-VC/InfixFunctions.jl
- Owner: Ismael-VC
- License: other
- Created: 2017-11-04T03:30:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-04T13:45:34.000Z (over 8 years ago)
- Last Synced: 2024-08-10T14:10:35.745Z (almost 2 years ago)
- Language: Julia
- Size: 20.5 KB
- Stars: 16
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# InfixFunctions
Julia infix function *hack*, based on this Python hack:
* http://code.activestate.com/recipes/384122-infix-operators
***
# Installation
```julia
julia> Pkg.clone("https://github.com/Ismael-VC/InfixFunctions.jl")
```
# Usage
```julia
julia> using InfixFunctions
julia> @infix foo(x, y) = x + y
foo (generic infix function with 1 method)
julia> @infix function foo(x::T, y::T) where {T<:Int}
return Complex(x + y)
end
foo (generic infix function with 2 methods)
julia> @infix (foo(x::T, y::S)::S) where {T<:Int, S<:Float64} = x - y
foo (generic infix function with 3 methods)
julia> 3.0 |foo| π
6.141592653589793
julia> 3 |foo| 5
8 + 0im
julia> 3 |foo| 5.
-2.0
julia> @infix div
INFO: div has been infixified
div (generic function with 31 methods)
julia> 10 |div| 5
2
```