As most people will tell you, the prefix notation is more natural in
Lisp-like languages. However, I sometimes wonder if adding a Haskell
infix operator (grave accent changes the argument order) could be a
good idea in some situations; for example (2 `+ 3) -> (+ 2 3).

On Nov 28, 3:54 pm, Dmitri <[EMAIL PROTECTED]> wrote:
> First of I'd like to say that I find Clojure to be an excellent
> language, however I find the lack of infix operators makes reading
> equations somewhat unnatural, eg:
>
> (+ (- (* x x) (* y y)) a)
>
> I ended up writing a simple function to handle infix notation
>
> (defn infix [arg1 func arg2 & args]
>     (let [result (func arg1 arg2)]
>         (if (= args nil) result (recur result (first args) (second
> args) (rrest args)))))
>
> using that I find makes the code more readable:
>
> (infix (infix x * x) - (infix y * y) + a)
>
> I was wondering if there is a more elegant way to do this, and if it
> could be added as a standard or contrib function.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to