I'm developing some simulation software in Clojure that will need to process lots of vector data (basically originating as offsets into arrays of Java floats, length typically in 10-10000 range). Large numbers of these vectors will need to go through various processing steps - e.g. normalising the vectors, concatenating together two streams of vectors, calculating a moving average etc.
Rather than doing everything in an imperative style, I was hoping to do was create a more functional-style Clojure solution that would do the following:
Does this sound like a sensible approach?
If so, any implementation hints or libraries that might help?
In a functional language, everything is dataflow. You can use functions as your module concept.
To address each of your use-cases:
(def module-a some-function)
To allow for easy extension by modules, I suggest using a Clojure map as your state, where one field is your array of floats.(def combined-module (compose module-a module-b)
:moving-average
field, then the keyword :moving-average
is your accessor function. State is not stored in modules.