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 money | |
(:refer-clojure :exclude [+]) | |
(:require | |
[clojure.spec.alpha :as s]) | |
(:import | |
(java.util | |
Currency))) | |
(s/def ::amount nat-int?) | |
(s/def ::currency #(instance? Currency %)) |
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
module MyPrelude where | |
import Prelude hiding (filter, foldl, foldr, map, reverse) | |
foldLeft :: (b -> a -> b) -> b -> [a] -> b | |
foldLeft _ acc [] = acc | |
foldLeft f acc (x:xs) = foldLeft f (f acc x) xs | |
reverse' :: [a] -> [a] | |
reverse' = foldLeft (flip (:)) [] |
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
scala> enum ShippingCategory: | |
| case UsLocalState, UsRemoteState, International | |
| | |
// defined class ShippingCategory | |
scala> object Address: | |
| class AddressInfo(val country: String, val state: String) | |
| | |
| def apply(country: String, state: String) = AddressInfo(country, state) | |
| |
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
#!/usr/bin/env bash | |
# npm install -g reveal-md | |
reveal-md tdd-with-rdd.md --theme night --highlight-theme monokai-sublime -w $@ |
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 clj-tdd-with-rdd.core | |
(:require | |
[clojure.spec.alpha :as s] | |
[clojure.string :as str])) | |
(s/fdef fizzbuzz | |
:args (s/cat :n pos-int?) | |
:ret string?) | |
(defn fizzbuzz [n] |
- 法学部出身のITエンジニア
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 do-notation | |
(:require | |
[clojure.math])) | |
;;; monad protocol | |
(defprotocol Monad | |
(return [this x]) | |
(bind [this f m])) |
NewerOlder