Skip to content

Instantly share code, notes, and snippets.

@Biacco42
Created February 14, 2018 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Biacco42/32df6eadf21d3ea923b9cabacf0e92fa to your computer and use it in GitHub Desktop.
Save Biacco42/32df6eadf21d3ea923b9cabacf0e92fa to your computer and use it in GitHub Desktop.
(ns study01.core
(:gen-class)
(:require [clojure.core.match :refer [match]]))
(defn fizz-buzz [nums]
(as-> nums input
(map #(match [(mod % 3) (mod % 5)]
[0 0] "FizzBuzz"
[0 _] "Fizz"
[_ 0] "Buzz"
:else %) input)))
(defn fib-rec [num pre-prev prev res]
(cond
(= 0 num) res
:else (fib-rec (- num 1) prev (+ pre-prev prev) (conj res pre-prev))))
(defn fib [num]
(fib-rec num 0 1 []))
(defn -main [& args]
(println (fizz-buzz (range 1 20)))
(println (fib 20)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment