News for hackers. Stuff that matters.
Re:Ask HN: what's up with HN and Lisp? by SamReidHughes on Monday February 14, 2011 @12:25AM (#2215426)
Oh, Perl. In some cases, Lisp would certainly be more verbose. It's probably more tedious than Perl for some things. It also depends on which language you use. Scheme is more tedious than Common Lisp, which is sometimes more tedious than Clojure.

Here are the Clojure equivalents, omitting the act of assigning stuff to variables.

    (map #(a-list %) '(3 1 4))

    ; I'm not modifying x in-place because unfortunately Clojure
    ; doesn't like that.  Common Lisp is more imperative.
     (.replaceAll x foo "BAR")

    ((colored-objects :red) 2)

    (str "Sorry, but " thing1 " doesn't work with " thing2 ".")

    (doseq [i (reverse (range 1 11))]
      (println "Counting down: " i))
If you took the first example and assigned it to a variable other-list, it would typically be in a let expression, with a body.

    (let [other-list (map #(a-list %) '(3 1 4))]
      (subsequent statements that use other-list))
Re:Ask HN: what's up with HN and Lisp? by igneous4 on Monday February 14, 2011 @08:34AM (#2216669)
Thanks for those equivalents, Sam! Informative.

That first `(map #...)` is particularly interesting. Looks like you're applying the item lookup operation across the list of indices. Neat.

Re:Ask HN: what's up with HN and Lisp? by SamReidHughes on Thursday February 17, 2011 @06:39AM (#2230595)
The first example could actually have been

    (map a-list [3 1 4])