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
(ns unicode.emoji | |
"Parses Unicode.org Emoji specifications." | |
(:require [clojure.java.io :as io] | |
[clojure.string :as cs])) | |
(defn slurp-lines | |
"Returns lines from unicode emoji file. Optionally reads file of same name | |
from resources." | |
[file & [resource?]] | |
(-> (if resource? |
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 parts | |
"Returns integer partitions for n." | |
([n] | |
(parts n n [] [])) | |
([n m acc prefix] | |
(if (= 0 n) | |
(conj acc prefix) | |
(reduce | |
(fn [st i] | |
(into st (parts (- n i) i acc (conj prefix i)))) |
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
(ns playground.test | |
(:require [clojure.spec.alpha :as s] | |
[clojure.spec.gen.alpha :as sgen] | |
[clojure.spec.test.alpha :as stest] | |
[clojure.string :as cs] | |
[clojure.walk :as walk])) | |
(def op-keys #{:and :or}) | |
(s/def ::expression |
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
// A sequence of integers is defined as F(N) = F(N-1) * F(N-2), | |
// with F(0) = 1 and F(1) = 2. | |
// Write a function which, given N, prints N and F(N) | |
// f(2) = F(2-1) * F(2-2) = F(1) * F(0) = 2 * 1 = 2 | |
// f(3) = f(3-1) * f(3-2) = f(2) * f(1) = 2 * 2 = 4 | |
// f(4) = f(4-1) * f(4-2) = f(3) * f(2) = 4 * 2 = 8 | |
// f(5) = f(5-1) * f(5-2) = f(4) * f(3) = 8 * 4 = 32 | |
// f(6) = f(6-1) * f(6-2) = f(5) * f(4) = 32 * 8 = 256 | |
// recursive |
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
open System | |
// Data types // | |
/// Describes an Address, its physical location, and the times it will be occupied. | |
[<StructuredFormatDisplay("{Name}")>] | |
type Address = { | |
Name: string | |
Street: string | |
City: string |
NewerOlder