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 groupBy[A](xs: List[A]): Map[A, Int] = | |
xs.foldLeft(Map[A, Int]()) { (m: Map[A, Int], x: A) => m + (x -> (m.get(x).getOrElse(0) + 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
subset NonNegativeInt of Int where * >= 0; | |
proto fib (|) is cached returns NonNegativeInt {*} | |
multi fib (0) { 0 } | |
multi fib (1) { 1 } | |
multi fib (NonNegativeInt $n) { fib($n - 1) + fib($n - 2) } | |
say fib(100) |
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 ajax-to-websocket.core | |
(:require [org.httpkit.server :as server] | |
[org.httpkit.client :as client] | |
[clojure.data.json :as json] | |
[clojure.data :as data] | |
[clojure.core.async :refer [chan <! >! go timeout onto-chan]])) | |
(defn channel-closed | |
"called when websocket channel is closed" | |
[status] |
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
lazy semantics and lambda abstractions | |
point-free in style and pure computation | |
memoization gives simple caching | |
these are a few of my functional things | |
when the state bites | |
when the C stings | |
when impure is bad | |
I simply remember my functional things | |
and then I don't feel so mad |
NewerOlder