Clojush icon indicating copy to clipboard operation
Clojush copied to clipboard

Where is the convenience function for `make-pushstate-with-specified-stacks`?

Open Vaguery opened this issue 9 years ago • 3 comments

I can't believe there isn't one tucked away somewhere. I don't want to create a redundant one.

Vaguery avatar Jul 14 '15 14:07 Vaguery

make-push-state makes a push state with all the stacks. Do you mean a state with specific items pushed onto specified stacks? If so, we don't have one. Though, I've never found it that inconvenient to do something like this:

(->> (make-push-state)
  (push-item input5 :input)
  (push-item input4 :input)
  (push-item input3 :input)
  (push-item input2 :input)
  (push-item input1 :input)
  (push-item "" :output))

thelmuth avatar Jul 14 '15 14:07 thelmuth

No, that's what I'm trying to avoid doing. I mean something where the call signature looks more like this:

(setup-push-state 
  :integer (1 2 3 4 5)
  :input ("foo" '(7 2 false) [1 3 5 7])
  :float (1.2 -99.5 0.0))

Is there a technical reason why the push-state should be built one step at a time instead of all at one go?

Vaguery avatar Jul 14 '15 14:07 Vaguery

Push states are just maps, so this is also easy to do:

(assoc (make-push-state)
  :integer '(1 2 3 4 5)
  :input '("foo" '(7 2 false) [1 3 5 7])
  :float '(1.2 -99.5 0.0))

That works for me. Note that I added quotes before each of your lists, since otherwise they're functions ;)

thelmuth avatar Jul 14 '15 15:07 thelmuth