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 receive
> > 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 sol
> 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
gt; On Mon, 2 Aug 2010 07:23:12 -0400
>
> Andrew Boekhoff 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 cal
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 *ns*)
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 11
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 t
> > 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 parameteriz
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 M
> > (: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.se
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 co
11 matches
Mail list logo