-
Notifications
You must be signed in to change notification settings - Fork 1
/
stash.cljc
49 lines (33 loc) · 1.15 KB
/
stash.cljc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(ns fif.stack-machine.stash
"Functions for manipulating the stack machine mode stash. The stash is
used by individual modes for storing information in between steps."
(:require
[fif.stack-machine :as stack]
[fif.utils.stash :as utils.stash]))
(defn get-stash
"Gets the stash. Note that it is stash2, since this is going to
replace the deprecated stash functionality which used 'sub-stacks'"
[sm]
(stack/get-mode-stash sm))
(defn set-stash
"Set the stack-machine stash to the given stash."
[sm stack]
(stack/set-mode-stash sm stack))
(defn new-stash
"Initialize a new stack-machine stash, or replace it with "
([sm coll]
(let [stash (get-stash sm)]
(set-stash sm (utils.stash/new-stash stash coll))))
([sm] (new-stash sm {})))
(defn clear-stash
[sm]
(set-stash sm (utils.stash/create-stash)))
(defn update-stash [sm f & args]
(let [stash (get-stash sm)]
(set-stash sm (apply utils.stash/update-stash stash f args))))
(defn remove-stash [sm]
(let [stash (get-stash sm)]
(set-stash sm (utils.stash/remove-stash stash))))
(defn peek-stash [sm]
(let [stash (get-stash sm)]
(utils.stash/peek-stash stash)))