This file contains hidden or 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
(fn fb [acc tamanho] | |
(if (< (count acc) tamanho) | |
(recur (conj acc (apply + (take-last 2 acc))) tamanho) | |
acc)) | |
(fb [1 1] 6) |
This file contains hidden or 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
(use 'clojure.set) | |
(def data | |
{:Hailey {"Broken Bells" 4, | |
"Deadmau5" 1, | |
"Norah Jones" 4, | |
"The Strokes" 4, | |
"Vampire Weekend" 1} | |
:Veronica {"Blues Traveler" 3, |
This file contains hidden or 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
(use 'clojure.set) | |
(use 'clojure.math.numeric-tower) | |
(def data | |
{:Hailey {"Broken Bells" 4, | |
"Deadmau5" 1, | |
"Norah Jones" 4, | |
"The Strokes" 4, | |
"Vampire Weekend" 1} |
This file contains hidden or 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
(+ (* (+ 1 2) 3) 4) | |
(-> (+ 1 2) (* 3) (+ 4)) |
This file contains hidden or 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
(defn x [map key] | |
(conj map {key (count map)})) | |
(defn rec [f numbers acc] | |
(if (empty? numbers) | |
acc | |
(recur f (rest numbers) (f acc (first numbers))))) | |
(prn (rec x [:a :b :c] {} )) |
This file contains hidden or 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
(def rec | |
(fn [f numbers acc] | |
(if (empty? numbers) | |
acc | |
(recur f (rest numbers) (f acc (first numbers)))))) | |
(prn (rec * [4 2 3] 1 )) |
This file contains hidden or 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
(def rec | |
(fn [n acc] | |
(if (empty? n) | |
acc | |
(recur (rest n) (+ acc (first n)))))) | |
(prn (rec [4 3 2 1] 0)) |
This file contains hidden or 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
(def fatorialT | |
(fn [n acc] | |
(if (= n 0) | |
acc | |
(fatorialT (dec n) (* acc n))))) | |
(prn (fatorialT 5 1)) |
This file contains hidden or 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
(def fac (fn [n] (apply * (range 1 (+ n 1) )))) |
This file contains hidden or 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
(def square (fn [n] (n * n))) | |
(def sum (fn [list] (apply + list))) | |
(def add-square (fn [list] (sum (map square list)) )) |