Re: data associated with a particular state

2014-03-26 Thread Atamert Ölçgen
I would use 3 records: (defrecord DownNode [] SomeInterfaceApplicableToDownState (wake-up [_] (->WaitingNode)) ... InterfaceApplicableToAllNodes ...) (defrecord WaitingNode [] SomeInterfaceApplicableToWaitingState (shutdown [_] (->DownNode)) (execute [_ job-id] (->RunningNode job-

Re: data associated with a particular state

2014-03-25 Thread László Török
AFAIK the only thing that records do not support compared to StructMaps is namespaced keyword lookup, i.e. (:some-ns/a-key a-record). If you do not need this, you should consider using records. Las On Tue, Mar 25, 2014 at 4:52 PM, Moritz Ulrich wrote: > The data type created by defstruct isn't

Re: data associated with a particular state

2014-03-25 Thread Moritz Ulrich
The data type created by defstruct isn't anything more than a map which can store the specified fields a bit more efficient than 'normal' maps. You can just `assoc' any other key-value pairs as in any other map. Also, have a look at records - I think StructMaps have been deprecated (or at least ar

data associated with a particular state

2014-03-24 Thread cmhoward2
Hi. I'm very new to Clojure, but I've read most of the functional programming tutorial . Suppose I have a data structure called "node" that can be in one of a number of different states -- namely, "down", "waiting", and "running". Suppose that i