Created
January 14, 2022 17:28
-
-
Save favila/1adac2b1adc61a856a081263d0484176 to your computer and use it in GitHub Desktop.
clojure datafy and nav to explore an open-ended state space
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 nav-> [x p] | |
(nav x p (get x p))) | |
(defn array-game-inc [x k v] | |
(with-meta | |
(assoc x k (inc v)) | |
(meta x))) | |
(defn array-game [] | |
(with-meta | |
[0 0 0 0] | |
{`clojure.core.protocols/datafy #'identity | |
`clojure.core.protocols/nav #'array-game-inc})) | |
(-> (array-game) ;[0 0 0 0] | |
(nav-> 0) ;[1 0 0 0] | |
datafy | |
(nav-> 0) ;[2 0 0 0] | |
datafy | |
(nav-> 0) ;[3 0 0 0] | |
datafy | |
(nav-> 1) ;[3 1 0 0] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment