On 19/06/12 13:06, Tassilo Horn wrote:
Well, if you memoize a fn of no args, it'll always return the same
value. If that's really what you want, I'd rather use
(def the-map (expr-calculating-the-map))
It needs to be a fn because a couple of slots in the map call a specific
fn that is not yet defined and I can't simply declare it so i get error
"attempting to call unbound fn"... I also cannot rearrange the code cos
the map is used all over the place - it needs to be at the top of the
namespace...
If it needs to be a function for some reason, then I'd use
(def gimme-the-map (constantly (expr-calculating-the-map)))
hmmm...when you say "(expr-calculating-the-map)" you mean the map
literal {} or the fn I already have?how is that cheaper since i am
calling the fn as brand new every time? is there some magic behind
constantly?
to make things clearer here is the actual map...as i said i can't def it
due to the call to 'starting-checkers' which needs the map to get the
colors...so i either get a stack overflow error or a "attempting to call
unbound fn"...
{:name 'checkers
:players 2
:colors (checkers-colors 'RED 'YELLOW)
:characteristics [:color :position :rank :value]
:board-size 32
:total-pieces 24
:rel-values {:soldier 1 :prince 3}
:board-atom current-checkers
:record-name "Clondie24.checkers.CheckersPiece"
:mappings board-mappings-checkers
:north-player-start (starting-checkers true)
:south-player-start (starting-checkers false)}
Jim
--
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