28 karma · joined May 4, 2010 (16y ago) · 42 submissions
comment 12y ago · link · parent
(-> 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.comment 12y ago · link · parent
comment 13y ago · link · parent
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).
comment 13y ago · link · parent
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.
comment 13y ago · link · parent
comment 13y ago · link · parent
comment 14y ago · link · parent
comment 14y ago · link · parent
You are making the same mistake that people that have Misconception 1 make. "The algorithm must make <a set of functions> comparisons." is a nonsensical statement.
comment 14y ago · link · parent
23.
Ask HN: Examples of Complecting
1 points · by oskarkv · 14y ago · discuss
comment 14y ago · link · parent
comment 14y ago · link · parent
comment 15y ago · link · parent
Maybe it's just me, but I find the documentation to be very good. Everything on clojure.org is relevant, clear and concise. I read two books too, but I learned the most from clojure.org.
comment 15y ago · link · parent