Skip to content

Instantly share code, notes, and snippets.

@st98
Last active January 4, 2016 02:49
Show Gist options
  • Select an option

  • Save st98/8557600 to your computer and use it in GitHub Desktop.

Select an option

Save st98/8557600 to your computer and use it in GitHub Desktop.
Clojureの練習。FizzBuzzです。
(ns fizzbuzz-clojure)
(defn- fizz? [x]
(= 0 (mod x 3)))
(defn- buzz? [x]
(= 0 (mod x 5)))
(defn- fizzbuzz? [x]
(and (fizz? x) (buzz? x)))
(defn- fizzbuzz [x]
(cond
(fizzbuzz? x) "FizzBuzz"
(fizz? x) "Fizz"
(buzz? x) "Buzz"
:else (str x)))
(defn fizzbuzz-seq [x]
(map fizzbuzz (range 1 (inc x))))
(load-file "fizzbuzz.clj")
(refer 'fizzbuzz-clojure :only '[fizzbuzz-seq])
(doseq [x (fizzbuzz-seq 100)]
(println x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment