Hacker News new | ask | show | jobs
by sundarurfriend 992 days ago
> I started wishing Julia had a swap for operators

You can define one pretty easily:

    julia> swap2(f::F) where F<:Function = (a, b) -> f(b, a)
    swap2 (generic function with 1 method)

    julia> swap2(-)(3, 5)
    2
(Perhaps you meant you wished it was pre-defined with the language, I understand the slight friction of having to define things for every project; this is just making sure you know it can be done pretty easily.)