News for hackers. Stuff that matters.
Re:Haskell One Liners to Impress Your Friends by jhuni on Saturday June 04, 2011 @05:31PM (#2620519)
Flipped curried operator? You mean like this:

  (defn flip-arguments
    [func]

    (fn [& args]
      (apply func (reverse args))))

  (prn (partition-by (partial (flip-arguments <) 60) [49 58 76 82 88 90]))
I noticed Haskell does automatic currying. You can easily create that or basically any other language feature using Lisp macros:

  (defn currify
    [f n]

    (fn [arg]
      (if (= n 1)
	(f arg)
	(currify (partial f arg) (dec n)))))

  (defmacro currying-function
    [arg-names & code-args]

    `(currify (fn ~arg-names ~@code-args) ~(count arg-names)))

  (def gt (currying-function [a b] (> a b)))
Once you experience the power of Lisp macros it is hard to go back to non-homoiconic languages such as Haskell that hide the underlying structure of the code.

I am not impressed by the Haskell code shown here, flipping and currying are feature Lisps had back in the 1980s or earlier, before Haskell was born.

Actually, I find the Haskell code rather revolting. First of all because of the horrid camel-case names (isInfixOf, parseXMLDoc, curlGetString, etc) then there is the very confusing syntactic constructs, like $ and <$>, and hard to interpret names like map, fmap, mapM_, foldl, and foldl1.

There are no comments on this comment yet.