Returning Success

2012-03-19 Thread Narvius
I am writing a game in Clojure, and I often need some functions to return whether they succeeded in doing what they are supposed to do (for example, moving that unit one field to the left may fail due to... I don't know, a wall?). But if there is one thing I really like about LISPs is the idea

Re: Returning Success

2012-03-20 Thread Narvius
Alright. 1) Why I need success state: this is a turn-based game, and I want to advance the world clock if and only if the player makes a valid move. 2) identical? makes sense. I generated some unnecessarily large data structure and checked, it really is ridiculously fast. Thanks! 3) Returning ni

Re: want to make a 'debug' function, how to get current source and line number?

2011-12-16 Thread Narvius
(defmacro dbg [x] `(let [x# ~x] (println (str *file* ":") "[" '~x "=>" x# "]") x#)) I personally use this macro. It shows only the file name (I can't find out how to get the current line number). This one has the advantage of still returning the same value as the expression itself. On D

lazy-seq and recursion.

2011-12-16 Thread Narvius
Hello, I just read some of the clojure.core source, and when reading map and range, I noticed that inside lazy-seq, recursion doesn't seem to stack overflow. I then tried it myself on some trivial examples, and indeed, I can take hundreds of thousands of entries from such a list without anything h

Re: want to make a 'debug' function, how to get current source and line number?

2011-12-16 Thread Narvius
(defmacro dbg [x] `(let [x# ~x] (println (str *file* ":") "[" '~x "=>" x# "]") x#)) Without the line number, because I don't know how to retrieve (neither could I find anything on it). On Dec 15, 6:48 am, jaime wrote: > Hello there, > > I want to write a function named "debug" which w

Re: lazy-seq and recursion.

2011-12-17 Thread Narvius
Hey, I got myself a copy of The Joy of Clojure. It's a fascinating read, thanks for the recommendation! N. On Dec 16, 4:10 pm, Tassilo Horn wrote: > Narvius writes: > > Hi Narvius, > > > So, my question is, why exactly DOESN'T it crash and burn horribly > > w

AoT Compilation fails

2012-01-08 Thread Narvius
Hello. I'm currently hacking away at a small project (turn-based game) that as of now spans over 7 namespaces/files. I'm working in an emacs/lein/swank environment. lein run works without problems. lein compile/jar/uberjar fails, yelling NullPointerException at game.clj:1. (slime-compile-and-load