oskarkv
Joined 16 years ago
Karma
28
Submissions
42
Member since
May 4
Joined 16 years ago
(-> state
(assoc :a val)
(update-in [:b :c] f args)
(dissoc :d)
(some-other-fn args))
where :a - :d are keys.Or you could use monads in much the same way as you would in Haskell; there are libs for that.
Or you could write a new macro (or maybe even function) that does exactly what you want. I did that for a game. It looked like this:
(call-update-fns game-state hook
(update-monster-positions)
(update-monster-ai)
(let-characters-attack)
(some-other-stuff))
It would thread the game-state (immutable) through all the functions, and call hook (a function) in between all the functions to send network messages and stuff (to minimize latency), and also collect and return new events that the functions created that I needed to handle (e.g. someone died when the characters attacked). It's almost like the state monad but not quite.Second, talking about O(g(n)) does not imply that the time complexity being discussed is the worst-case (or any other case) time complexity. One could for example say that the algorithm A's best-case time complexity is in O(n), and it's worst-case time complexity is in O(n^2).
I'm coming from Clojure, and I'm interested in Chicken. I really like the things mentioned above about Clojure and I am just interested in how Chicken compares when it comes to these things.