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
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* (.
/
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
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
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
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
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
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
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 %))
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.
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
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
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
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...
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
15 matches
Mail list logo