I have a project in which I have to use some java mutable objects
(e.g. a graph).
In my code, I have some functions that get these objects and add nodes
to them, for instance:
(defn make-graph [] returns a graph wrapped with other things)
(defn add-to-graph [graph n] adds n to the
A solution using recur:
(defn flatten-maps-recur
([ms] (flatten-maps-recur ms ()))
([ms fl] (if-let [[f r] (seq ms)]
(recur (concat (get f :c) r) (cons (dissoc f :c)
fl))
fl)))
Please, can you publish how are you doing your timings?
Thanks,
JM
I was asking because my timings show that the lazy version is the
fastest one.
My (very simple stupid) test is:
(defn flatten-maps
The original one
)
(defn flatten-maps-lazy
The lazy one
)
(defn flatten-maps-eager
The eager one
)
(defn flatten-maps-recur
Do protocols respect namespace rewriting? For instance:
We define a protocol in a namespace:
(ns a)
(defprotocol P
(p [this]))
(defn g[] )
This works:
(ns b
On 6 abr, 00:02, Stuart Sierra the.stuart.sie...@gmail.com wrote:
You can omit clojure.core/first from your namespace like
I'm having trouble avoiding name collisions with protocols. A third-
party librery defines:
(ns a)
(defprotocol PA
(fa [this ...])
(ga [this ..])
(ha [this ..])
.)
And i want to be able to use some of this protocol for a type I'm
defining. So I do
(ns b
(:use a :as mya))
It has worked like a charm.
Thanks.
Juan Manuel
On 11 abr, 16:45, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
On 11 Apr., 16:35, babui jmgim...@gmail.com wrote:
(ns b
(:use a :as mya))
You want require here, not use. (ns b (:require [a :as mya]))
Sincerely
Meikel
--
You
I've been playing with lazy sequences defined by autoreferential
definition. For instance:
(def ones (lazy-seq (cons 1 ones)))
which is equivalent to (def ones (repeat 1)).
My problem arises when defining the sequence of fibonacci numbers.
With this definition:
(def fibs
(lazy-seq (list* 0 1
,
On Fri, Nov 19, 2010 at 11:44 AM, babui jmgim...@gmail.com wrote:
I've been playing with lazy sequences defined by autoreferential
definition. For instance:
(def ones (lazy-seq (cons 1 ones)))
which is equivalent to (def ones (repeat 1)).
My problem arises when defining the sequence
simply don't put a for inside a for:
(for [x (range 5)
y (range 5)]
y)
Hope this helps.
JM
On 19 oct, 06:57, Rising_Phorce josh.fe...@gmail.com wrote:
Nested For(s) produce lists of lists:
=(for [x (range 5)]
(for [y (range 5)]
y))
((0 1 2 3 4) (0 1
On 12 oct, 03:56, Stuart Halloway stuart.hallo...@gmail.com wrote:
I've tried your definition
(def primes
(concat
[2]
(let [primes-from
(fn primes-from
[n]
(if (some #(zero? (rem n %))
(take-while #(= (* % %) n) primes))
Hi all,
does anyone knows if (and where) the presentation Rick gave at
the Emergin Languages Summit is available?
Thanks,
Juan Manuel
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
BTW, it's Rich, not Rick
Sorry, Rich.
JM
PS: I hope this messsage does not contain any error :-)
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are
12 matches
Mail list logo