I'm not sure if this is the place to ask this but I've been struggling
with a few things in the world of Clojure. I've been using Processing
to learn Clojure (since I'm somewhat familiar with Processing) but the
tough part has been dealing with things like x, y positions of objects
without keeping some global state (I'm not sure if it's even
possible).

The code in question is: https://gist.github.com/887256

All this does is bounce a ball around a screen, for every frame
Processing calls draw which moves the ball one frame. Since I'm not
the one driving the loop I ended up using atoms to update some bits of
global state but that feels really dirty.

If I could drive the frames it would be easy to use recur or some
other bit of state passing as I render each successive frame. I've
considered using sequences and passing a frame number (which would be
stored in a global as well) in but then it'd (I assume) have to run
through every number up to that the one I passed it. Seems like
performance would degrade the longer it ran. There's also this idea
rattling around in my head where I'd just rewrite the function
everytime with the new state - but seems like you couldn't scale that
to multiple balls bouncing around (which is the next step) - and God
knows what, if any, performance implications that would have.

So I'm not sure where that leaves me - learning functional stuff can
be wonderfully mind breaking but sometimes I feel like I don't even
have the tools in my head to work some things out. Is there some
technique I'm missing for dealing with state between successive calls
of a function?

How would you solve something like this?
-Brandon

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to