Created
February 14, 2018 18:17
-
-
Save Biacco42/32df6eadf21d3ea923b9cabacf0e92fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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