Mad maxer clojure help?

i am very enthusiast to learn clojure. but it is look like very hard to solve some simple problem. for example for mad maxer this is my code:

  (def aSqh (fn [target] (.distanceTo this target)))
  (let [enemies (.findEnemies this)
        enemy    (.findNearest this enemies)]
        (if enemy 
            (when true 
            (def mDenemies (apply max (map aSqh enemies)))
            (.say this mDenemies)

but it face the error that
"[object object] is not the number"
is any one know the solution and in addition, is there anyone like to work together to learning clojure with sharing the knowledge

I’m surprised it worked that well. When ever I try anything “Fancy” it just gets silently swallowed.

I tested stuff and “aSqh” works, “apply” works, but map looks like it gets defined to something but never “executes” (at least not properly).

which is the “[object Object]” you are trying to “apply max” to. I have no idea how to get map to return the […] that it should. I also get the “[object Object]” sometimes when trying to play with position objects ({:x x :y y}) so I know that at least sometimes it has to do with it gettng messed up between javascript and clojure datatypes.

As it says “Experimental”, although sometimes I think it is just “Mental” (the Clojure transpiler).
I haven’t done this level yet (in Clojure) still working my way through the forest.
But the only solution I’ve found for such things is to write it out yourself. iow:

(def index 0)
(while (< index (count enemies))
    ;; blah blah (if (> curDist maxDist) (;;blah blah

thanks Vlevo, I do that till this level with Clojure but I think need group working and because of pure function property of clojure (however it is not so pure) and with respect to the the recursion vs. iteration, thus it is better to not simply put max in some value and changed it in each iteration. and then problem started here as you see …

Yeah, it would be nice if we could do things in the idiomatic way (for the different languages) but at the moment the closure transpiler is rather mental (there are several things wrong with it). :fearful: So we have to make do with what we have. :frowning:

1 Like

can someone post a code that works
i have been stuck for days and its a school project
due very soon

I see so you wish for cheating… (I’m sure you’ll find some loser to just post his code, but no one should.)

Post what you have, and what is not working like you expect and we’ll happily help you figure it out. That is how learning usually works. (Yes, one CAN learn by looking at working code but that also takes work, copy&paste not equal learning and CodeCombat is about learning.)


how do i find this loser although i wouldn’t call him a loser, i would call them a bro, or just a helpful person
but if you think the eleventh commandment is thou shalt not share codes on code combat that’s up to you

Now you are just trolling…

Please keep it civil everyone if you need help we will walk you through to process to get the answer
to the problem


i’m not trolling i’m just looking for code thank you for your help

You won’t get it. We don’t give away code here. We expect you to post yours and get assistance fixing it.