4 ms·
This seems conceptually similar to the threading macro "->>" in Clojure, as well as the pipe operator "|>" in elixir. (defn divisible? [x y] (zero? (
by taylorlapeyre 12y ago
This seems conceptually similar to the threading macro "->>" in Clojure, as well as the pipe operator "|>" in elixir.
(defn divisible? [x y]
(zero? (rem x y)))
(defn fizzbuzz [n]
(cond (divisible? n 15) "Fizzbuzz"
(divisible? n 3) "Fizz"
(divisible? n 5) "Buzz"
:else n))
(->> (range 100)
(map fizzbuzz)
(apply println))
- mjn 12y agoHere's a direct implementation of the Clojure -> and ->> macros in CL: https://github.com/nightfly19/cl-arrows/blob/master/arrows.lisp https://github.com/nightfly19/cl-arrows/blob/master/arrows.l... 'fogus also points out that the Dylan compose function is similar, and that 'pg provides an implementation of that in his book ANSI Common Lisp: http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/ http://blog.fogus.me/2009/09/04/understanding-the-clojure-ma...