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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
const LoginMachine = Machine({ | |
id: 'loginMachine', | |
initial: 'credentialsForm', | |
states: { | |
credentialsForm: { | |
initial: 'iddle', | |
states: { | |
iddle: { | |
entry: ['parseAuthParamsFromQueryString', 'checkValidityOfAuthParams'], | |
on: { |
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
function getEffects(list, payload) { | |
if (list && list.length) { | |
return list.map((type) => { | |
if (typeof type === 'string') { | |
return put({ | |
type, | |
payload, | |
}); | |
} | |
return put(type); |
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
// Y Combinator | |
const Y = a => (b => b (b)) (b => a (c => b (b) (c))) | |
// isomorphic Church encoding/decoding | |
const Church = { | |
to: n => f => x => Array.from (Array (n)).reduce (f, x), | |
from: f => f (x => x + 1) (0) | |
} | |
const True = a => b => a |
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
(defn get-final-freq | |
"Day one: calculate resulting frequency" | |
[freq_list] | |
; 1. clojurist prefer to use `-` instead of `_` in names | |
; 2. I'm not sure how you got and what's inside `freq_list` (I suppose integers, then it's fine) | |
(reduce + freq_list)) | |
(defn repeated-freq | |
"Day one: first occur of repeated frequency" | |
[freq_list] |
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
(defn get-final-freq | |
"Day one: calculate resulting frequency" | |
[freq_list] | |
(reduce + freq_list)) | |
(defn repeated-freq | |
"Day one: first occur of repeated frequency" | |
[freq_list] | |
(reduce | |
(fn [vect freq] ( |