nth yields java.lang.OutOfMemoryError: Java heap space

2009-07-04 Thread arasoft
Using a fairly recent 1.1 snapshot, I get an OutOfMemoryError for this: (defn fib-seq [] ((fn more [a b] (lazy-seq (cons a (more b (+ a b) 0 1) ) (nth (fib-seq) 20) However, this works fine: (defn xth [coll i] (if (zero? i) (first coll) (recur (rest coll) (dec i

Would *default-precision* make sense?

2009-06-29 Thread arasoft
At least I believe so: it would allow client code to set the desired precision once and then be able to invoke functions that take an optional precision parameter (or none at all) without having to specify precision every time. For example: (set! *default-precision* (.

Re: Would *default-precision* make sense?

2009-06-29 Thread arasoft
/ establish root binding of: *math-context* with set (NO_SOURCE_FILE:0) whereas (set! *warn-on-reflection* true) works fine? What is the difference? How is it done right? On Jun 29, 2:24 pm, Christophe Grand christo...@cgrand.net wrote: On Mon, Jun 29, 2009 at 1:23 PM, arasoft t...@arasoft.de

Re: Would *default-precision* make sense?

2009-06-29 Thread arasoft
I'm obviously all for it... On Jun 29, 5:53 pm, Rich Hickey richhic...@gmail.com wrote: On Mon, Jun 29, 2009 at 10:51 AM, Stephen C. Gilardisquee...@mac.com wrote: On Jun 29, 2009, at 10:11 AM, Nicolas Oury wrote: I am not sure, but I believe it's due to *warn-on-reflection* being bound

Re: Trying to use lazy-seq for the first time, failing.

2009-06-27 Thread arasoft
I think you just forgot to return the value itself. This seems to work: (defn produce [value predicate generator] (when (predicate value) (let [result (generator value)] (cons result (lazy-seq (produce result predicate generator) ) And I would use quot instead of

How to generically coerce a number to the class of another number???

2009-06-24 Thread arasoft
Is there a way to avoid having to use a function like this (defn coerce-primitive-integer [value to-class] (cond (= to-class java.lang.Byte) (byte value) (= to-class java.lang.Short) (short value) (= to-class java.lang.Integer) (int value) (= to-class

Re: Small question: inserting something at the beginning of a vector

2009-06-24 Thread arasoft
This also works: (into [-1] [0 1 2 3 4]) but I am more than uncertain whether it is proper. On Jun 25, 12:26 am, CuppoJava patrickli_2...@hotmail.com wrote: I personally use (concat [-1] [0 1 2 3 4]), but I've never been happy with that either. I would be interested in the proper way of doing

Question regarding example in Stuart Halloway's book (page 120)

2009-06-24 Thread arasoft
Why does this work? (take-while (complement #{\a\e\i\o\u}) the-quick-brown-fox) When I do something similar, like (take-while (complement #(Character/isWhitespace %)) the-quick-brown- fox) I have to deal with the parameter explicitly (%). How is the parameter hidden in the set/function? Could

Re: Question regarding example in Stuart Halloway's book (page 120)

2009-06-24 Thread arasoft
Thank you for a comprehensive explanation!!! On Jun 25, 1:17 am, Richard Newman holyg...@gmail.com wrote: Why does this work? (take-while (complement #{\a\e\i\o\u}) the-quick-brown-fox) When I do something similar, like (take-while (complement #(Character/isWhitespace %))

Re: Poll for a new name for clojure eclipse plugin 'clojure-dev'

2009-06-23 Thread arasoft
Clojipsy clojure-eclipse On Jun 23, 1:47 pm, Laurent PETIT laurent.pe...@gmail.com wrote: Hello, Since the switch to git, there has also been the creation of a mailing list called clojure-dev for discussions concerning clojure development, and a twitter account also named clojuredev.

macroexpand question

2009-06-22 Thread arasoft
I just wrote my first practice macro, first without and then with syntax quoting: (defmacro take-until1 [function sq] (list 'take-while (list 'fn (vector 'x) (list 'not (list function 'x))) sq)) (defmacro take-until2 [function sq] `(take-while (fn [x#] (not (~function x#))) ~sq)) Both seem

Re: Question/Problem re (set! *warn-on-reflection* true)

2009-06-22 Thread arasoft
Thank you for your help. I have posted a message on the Enclojure group yesterday and I am still waiting for it to show up... On Jun 22, 5:46 am, Stephen C. Gilardi squee...@mac.com wrote: On Jun 21, 2009, at 11:17 PM, arasoft wrote: When I enter the following function into the REPL

(Potentially stupid) Question about recursion / trampoline

2009-06-10 Thread arasoft
I tried this: (declare F) (defn M [n] (if (zero? n) 0 (- n (F (M (dec n)) (defn F [n] (if (zero? n) 1 (- n (M (F (dec n)) and for large n I got the expected stack overflow. Then I tried to trampoline the functions: (declare F) (defn M [n] (if (zero? n) 0

Re: (Potentially stupid) Question about recursion / trampoline

2009-06-10 Thread arasoft
Thank you for the answers. I now understand why this cannot work with trampoline. Is there another way to avoid stack overflow? I'd like to submit the code to http://rosettacode.org/wiki/Mutual_Recursion to improve the Clojure coverage and also to learn more stuff myself...

Re: (Potentially stupid) Question about recursion / trampoline

2009-06-10 Thread arasoft
the same StackTrace problem. 2009/6/10 arasoft t...@arasoft.de: Thank you for the answers. I now understand why this cannot work with trampoline. Is there another way to avoid stack overflow? I'd like to submit the code tohttp://rosettacode.org/wiki/Mutual_Recursionto improve the Clojure