Re: probable bug in transients ..

2011-01-06 Thread Andrew Boekhoff
http://clojure.org/transients mentions that transients are not designed to be bashed in place like mutable datastructures. The following produces the correct result. (loop [x (transient {}) i 0] (if ( i 10) (recur (assoc! x i (* i i)) (inc i)) (persistent! x))) -- You

Re: Native Clojure

2010-12-21 Thread Andrew Boekhoff
With TCO mutually recursive functions do not consume the stack. The same is true for well constructed lazy sequences. If the functions were: (defn f [x] (g x)) (defn g [x] (f x)) They would operate in constant space with tail-call optimization. (defn f [x] (cons x (g x))) (defn g [x] (cons x

Re: Native Clojure

2010-12-21 Thread Andrew Boekhoff
Lazy-seq's are often handy in Clojure to subvert the stack limit imposed by the the JVM, but it's not quite the same problem that TCO solves. Having recently converted some Scheme that leaned heavily on the presence of TCO, I'm curious as to what situations you think could not be solved

Re: Symbol substitution in macro

2010-08-04 Thread Andrew Boekhoff
-0400 Andrew Boekhoff boekho...@gmail.com wrote: On Sunday 01 August 2010 21:34:16 Kyle Schaffrick wrote: Hello, I'm trying to write a library with two main parts. The first is a macro, I'll call it 'with-feature, that walks through forms passed inside it, and any time it sees

Re: Symbol substitution in macro

2010-08-02 Thread Andrew Boekhoff
On Sunday 01 August 2010 21:34:16 Kyle Schaffrick wrote: Hi, The following technique seems to work for finding out if you've been aliased: (ns somewhere.trial) (let [here *ns*] (defmacro whats-my-name [] (some (fn [[k v]] (when (= here v) `(quote ~k))) (ns-aliases

Re: Remove-first function

2010-07-24 Thread Andrew Boekhoff
Hi, One way to prevent the stack overflows is to wrap it in a lazy seq. For example: (defn remove-first [x coll] (lazy-seq (when (seq coll) (let [[y ys] coll] (if (= target y) ys (cons y (remove-first x ys))) On Saturday 24 July 2010

Re: congomongo memory leak?

2010-05-17 Thread Andrew Boekhoff
Hi. Congomongo is a fairly thin wrapper around the MongoDB java driver. All fetch requests are proxied through the driver which handles all opening and closing of connections automatically. Its main utility is providing a smooth(er) interface between Clojure's immutable types and the mutable

Re: Lift equivalent

2010-01-03 Thread Andrew Boekhoff
As for the OO vs functional . . . a web server is a function from a request to a response. How is that functional view any less natural than an OO view? I think someone steeped in the controller/action viewpoint (a la Rails) would disagree: they see requests as being parameterized

Re: Better documentation and error messages are needed for the ns macro

2009-11-13 Thread Andrew Boekhoff
With clojure-in-clojure on the horizon (if not around the corner) I wonder if an imports clause would be appropriate, and solve some of the complexities of discerning between clojure and java/clr/javascript/objectivec/(go?) (ns foo (uses clojure.contrib.repl-utils) (imports java.util [List

Re: Better documentation and error messages are needed for the ns macro

2009-11-11 Thread Andrew Boekhoff
(:uses [clojure.core :exclude [read]) [clojure.contrib.graph] [clojure.contrib.fcase] [clojure.contrib.stream-utils :as su] [clojure.contrib.def :refer-all true] [clojure.contrib.except :refer-all true] [clojure.contrib.server-socket

Re: Iterative collections.

2009-11-09 Thread Andrew Boekhoff
Hi. And gives very different results. 'for' iterates over it's sequences in a nested fasion. For your particular example, it will return the sequence from (+ 31 1) (+ 31 2) and so on, and never get to the second element of the first vector. I like it. I was recently wondering about a