Re: heaps in clojure

2011-09-15 Thread Sunil S Nandihalli
Thanks Jason, I think some sort of priority queue may be the solution. Thanks, Sunil. On Wed, Sep 14, 2011 at 12:39 AM, Jason Wolfe ja...@w01fe.com wrote: There is java.util.PriorityQueue, which is heap-based: http://download.oracle.com/javase/1,5.0/docs/api/java/util/PriorityQueue.html

Re: confusion with map and dosync

2011-09-15 Thread Matt Hoyt
Map is lazy so it only gets called when you need something from the sequence.   To force it to be called you use doall so it would be (doall (map queue-copy-fetch fetches-seq)). You only need the do sequence in queue-copy-fetch but not in process-indexes.   Matt Hoyt

Re: confusion with map and dosync

2011-09-15 Thread Luc Prefontaine
Map returns a lazy sequence, the list of values is not realized yet, you need to consume the lazy seq to obtain the values. You should use (doseq [f fetches-seq] (queue-copy-fetch f))) if you have only side effects to generate and do not care about reusing the values returned by

Re: confusion with map and dosync

2011-09-15 Thread Matt Hoyt
You only need the do sequence in queue-copy-fetch but not in process-indexes should be You only need the dosync in queue-copy-fetch but not in process-indexes.   Matt Hoyt From: Matt Hoyt mrho...@yahoo.com To: clojure@googlegroups.com clojure@googlegroups.com

Re: Rounding the edges of an Emacs beginner

2011-09-15 Thread Timothy Washington
Nice. Thanks Peter. I use the n, p and v navigations now, but always want to do that vim / Ctrl-d thing, lol. I figure I just need to spend some time getting used to emacs' navigation idioms. It's going to take a lot of doing to pull me away from vim habits. Tim On Wed, Sep 14, 2011 at 8:50 PM,

using finger trees in two dimensions

2011-09-15 Thread Sunil S Nandihalli
Hi everybody, Thanks to Chouser's finger tree data structure, it makes it very simple to keep some elements in a tree/sequence and efficiently maintain values by some associative operation on all the elements of the collection .. I guess chouser himself has given series of talks on that. However,

Re: Rounding the edges of an Emacs beginner

2011-09-15 Thread Stefan Kamphausen
Hi, we're getting totally OT here and should probably better head for gnu.emacs.help. Anyway, just one more bark from me and then I'll be quiet (but will respond to mail ;-) On Thursday, September 15, 2011 2:08:28 AM UTC+2, frye wrote: In Vim , you press *Ctrl-d* and *Ctrl-u* to go down and

autoboxing in 1.3 RC-0

2011-09-15 Thread Sergey Didenko
Hi, Is it a bug or I'm doing something wrong? I can't get rid of auto-boxing in the second example, neither by type hinting nor by type coercing of changed* locals. (set! *warn-on-reflection* true) This compiles fine: (loop [x 1 changed 0] (if (= x 10) changed (recur (inc x)

Re: heaps in clojure

2011-09-15 Thread Mark Engelberg
You can do one linear pass over your data, accumulating a sorted set of the best 10 items you've found so far. You seed the sorted set with the first 10 items from your list, then continue traversing your list. With each new item you encounter, you ask if it is any better than the worst of the

Re: heaps in clojure

2011-09-15 Thread David Powell
Does that work? There is no guarantee that the top 10 of the overall list matches the top 10 of earlier prefixes, so the candidates that get discarded might be part of the overall top 10, and the elements that pushed them out could just be local maxima. -- Dave On 15 Sep 2011 08:23, Mark

Re: heaps in clojure

2011-09-15 Thread Mark Engelberg
If you maintain the invariant that at each point, your sorted set contains the top 10 you've seen so far, then from that invariant you can conclude that at the end of the traversal, your sorted set contains the top 10 for the overall list. On Thu, Sep 15, 2011 at 12:34 AM, David Powell

Re: heaps in clojure

2011-09-15 Thread David Powell
But when an element is dropped from the list, you're effectively resetting its seen-count to zero. It might be seen again, and it might (if you hadn't reset the seen-count), have ended up in the top 10. Or have I misunderstood? -- Dave On 15 Sep 2011 08:54, Mark Engelberg

Re: heaps in clojure

2011-09-15 Thread Mark Engelberg
The initial problem statement is to figure out what would be the first 10 items if you sorted the list. I don't see anything about frequency or how many times you've seen a given item in the statement of the problem. When I talk about a best item, I mean it is the first with regard to whatever

Re: heaps in clojure

2011-09-15 Thread David Powell
Ah yeah. Sorry, I'd superimposed something I was thinking about on to the original problem. -- Dave On 15 Sep 2011 09:07, Mark Engelberg mark.engelb...@gmail.com wrote: The initial problem statement is to figure out what would be the first 10 items if you sorted the list. I don't see

Re: Mocking out namespaces

2011-09-15 Thread Chris Perkins
On Wednesday, September 14, 2011 11:19:13 AM UTC-4, Brian Hurt wrote: Say I have two name spaces, A and B, with A depending on B. I want to test namespace A, replacing module B with a mock B for testing purposes- preferably without having to load B at all (B sucks in a bunch of stuff,

Re: Overtone 0.3 released

2011-09-15 Thread Herwig Hochleitner
Thanks, Sam! I'm really looking forward to play a bit more in depth with overtone and try to use it in a jam session. kind regards -- __ Herwig Hochleitner -- You received this message because you are subscribed to the Google

Re: Binding *out*

2011-09-15 Thread Nick Mudge
Thanks Stuart and Dave. On Sep 14, 10:30 am, Stuart Sierra the.stuart.sie...@gmail.com wrote: Hi Nick, *out* and *err* are already dynamic, which is what allows `binding` to work. You can the  root binding of any Var (even non-dynamic Vars) with `def` or `alter-var-root`. -Stuart Sierra

Re: How to convert general recursion to loop .. recur syntax

2011-09-15 Thread Herwig Hochleitner
Hi, as you might know, the original version actually does run in fixed stack space, thanks to lazy sequences. (defn skl [tree] (map skl (filter seq? tree))) loop .. recur is the moral equivalent of a while(true) loop in imperative style. i.e. a slightly disguised (and somewhat more

Re: Clojure vs Scala - anecdote

2011-09-15 Thread cig
Impressive, wonder if they were running this on a single node or more widespread? In a wide spread environment I think Erlang would be the true winner, though it does not natively have macros :-( There is an implementation of Lisp for Erlang called LFE (lisp flavored Erlang) which I looked at,

Clojure videocast mentioning SuperCSV?

2011-09-15 Thread James P
I've been watching a bunch of Clojure videocasts lately, and there was one which mentioned using the Java library SuperCSV. Unfortunately I can't recall which videocast it was, can someone remind me please? Many thanks. -- You received this message because you are subscribed to the Google

Watching namespaces

2011-09-15 Thread Stathis Sideris
Hello, Is it somehow possible to monitor all namespaces for new defs or re- defs (and defns etc). Generally, it it possible to implement some sort of notification whenever something is added or updated to a namespace? I don't mind even the solution is hacky or not very fast. The reason I'm

Re: Watching namespaces

2011-09-15 Thread Herwig Hochleitner
I was about to say that you best bet would be redefining the relevant functions/macros, when I realized that you cannot do that with def, because it's a special form. So short of patching clojure, I don't think one can monitor var interning. (addition to a namespace) What you can do, is

ClojureScript auto-recompile option

2011-09-15 Thread Stuart Campbell
Hello, I've written a small hack for the ClojureScript compiler that is useful for working with static HTML projects. When invoked with the :watch option, the cljsc program watches a source directory and recompiles sources whenever a change is detected.

Re: How to convert general recursion to loop .. recur syntax

2011-09-15 Thread Chouser
On Thu, Sep 15, 2011 at 8:56 AM, Herwig Hochleitner hhochleit...@gmail.com wrote: Hi, as you might know, the original version actually does run in fixed stack space, thanks to lazy sequences. You are right! Without testing it I had thought that the way recursion was used would cause skl to

Re: Watching namespaces

2011-09-15 Thread Laurent PETIT
2011/9/15 Stathis Sideris side...@gmail.com Hello, Is it somehow possible to monitor all namespaces for new defs or re- defs (and defns etc). Generally, it it possible to implement some sort of notification whenever something is added or updated to a namespace? Not that I'm aware of. I

Re: How to convert general recursion to loop .. recur syntax

2011-09-15 Thread Ken Wesson
On Thu, Sep 15, 2011 at 8:56 AM, Herwig Hochleitner hhochleit...@gmail.com wrote: Consider (defn find-in-tree  ([tree pred?]    (concat      (filter pred? tree)      (mapcat find-in-tree (filter sequential? tree) (repeat pred?) which of course is much simpler written as (defn

Re: autoboxing in 1.3 RC-0

2011-09-15 Thread David Nolen
On Thu, Sep 15, 2011 at 3:18 AM, Sergey Didenko sergey.dide...@gmail.comwrote: Hi, Is it a bug or I'm doing something wrong? I can't get rid of auto-boxing in the second example, neither by type hinting nor by type coercing of changed* locals. (set! *warn-on-reflection* true) This

Re: Clojure vs Scala - anecdote

2011-09-15 Thread Sean Corfield
On Wed, Sep 14, 2011 at 11:15 PM, cig clifford.goldb...@gmail.com wrote: Impressive, wonder if they were running this on a single node or more widespread? We run an instance of the process on multiple nodes, configured slightly differently. We needed some parallelization to improve throughput

Re: ClojureScript gets defrecord

2011-09-15 Thread Devin Walters
Great news! Looking forward to trying it out this afternoon. Cheers, Devin On Sep 14, 2011, at 2:48 PM, Tom Hickey wrote: Hi all, With sign-off from Rich, I have pushed my defrecord work onto master. Please try it out and let me know if you experience any issues. Cheers, Tom Hickey

Re: Rounding the edges of an Emacs beginner

2011-09-15 Thread gaz jones
M-{ and M-} in emacs go forward/backwards a paragraph. when in code, this often translates well to moving around between fragments/functions etc. you also have C-v and M-v for forward/backward a page and then C-l for centering on the current line. i use all of those a lot... On Thu, Sep 15, 2011

Re: autoboxing in 1.3 RC-0

2011-09-15 Thread Sean Corfield
On Thu, Sep 15, 2011 at 7:50 AM, David Nolen dnolen.li...@gmail.com wrote: Loop itself will return boxed values I think. Looks that way. The following code has no reflection warning: (loop [x 1 changed 0] (if (= x 10) changed (recur (inc x) (long (loop [y 1 changed-y changed]

Re: Clojure vs Scala - anecdote

2011-09-15 Thread Edward Garson
Native Erlang does have a macro facility, but it is not as powerful as Lisp/Clojure's. On Sep 15, 2:15 am, cig clifford.goldb...@gmail.com wrote: [snip] In a wide spread environment I think Erlang would be the true winner, though it does not natively have macros :-( [snip] -- You received

Re: Clojure vs Scala - anecdote

2011-09-15 Thread Raoul Duke
On Thu, Sep 15, 2011 at 9:24 AM, Edward Garson egar...@gmail.com wrote: Native Erlang does have a macro facility, but it is not as powerful as Lisp/Clojure's. lfe, baby, though of course that is not native erlang. -- You received this message because you are subscribed to the Google Groups

java interop question: how to access Class object statically

2011-09-15 Thread Andrew Xue
Hi all -- Trying to basically do something like Integer.class -- but ... user= (Integer/class) user= java.lang.NoSuchFieldException: class (NO_SOURCE_FILE:2) user= (Integer/getClass) java.lang.NoSuchFieldException: getClass (NO_SOURCE_FILE:4) Some (not so pretty) workarounds are (.getClass

Re: java interop question: how to access Class object statically

2011-09-15 Thread Dave Ray
How about just Integer? :) Clojure Integer java.lang.Integer Clojure (class Integ­er) java.lang.Class Dave On Thu, Sep 15, 2011 at 1:31 PM, Andrew Xue and...@lumoslabs.com wrote: Hi all -- Trying to basically do something like Integer.class -- but ... user= (Integer/class) user=

Re: ClojureScript gets defrecord

2011-09-15 Thread David Nolen
Any particular reason that records print differently than in Clojure? I also see that records don't print w/ their namespace attached. A related bug I encountered was that when I try to put the record literal back into the REPL, Java complains about not being able to find the class. David On

Re: ClojureScript gets defrecord

2011-09-15 Thread Tom Hickey
Printing is not meant to be different. Maybe I was using against an older version of Clojure when I was comparing output. Should be fixed on master. Thanks for the report. Tom On Sep 15, 4:00 pm, David Nolen dnolen.li...@gmail.com wrote: Any particular reason that records print differently

Re: Watching namespaces

2011-09-15 Thread Chas Emerick
Yes, this has been suggested in the past, and would enable all sorts of useful tooling features. The off-the-top-of-my-head solution (a priori of a proper statement of the problem :-P would be for all namespaces (c.l.Namespace/namespaces) and each namespace's aliases and mappings to be held in

Re: autoboxing in 1.3 RC-0

2011-09-15 Thread Ken Wesson
On Thu, Sep 15, 2011 at 10:50 AM, David Nolen dnolen.li...@gmail.com wrote: On Thu, Sep 15, 2011 at 3:18 AM, Sergey Didenko sergey.dide...@gmail.com wrote: Auto-boxing loop arg: change (loop [x 1 changed 0]  (if (= x 10)    changed    (recur (inc x)           (loop [y 1 changed-y changed]

Re: How to convert general recursion to loop .. recur syntax

2011-09-15 Thread octopusgrabbus
Thanks for clarifying the stack space issue. I got confused with the original implementation, and was unsure it would run with a large sequence. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Clojure vs Scala - anecdote

2011-09-15 Thread Tal Liron
On Tuesday, September 13, 2011 1:44:09 PM UTC-5, Sean Corfield wrote: It was intended to be purely anecdotal but that doesn't seem to satisfy anyone! :) Homer: You know, when I was a boy, I really wanted a catcher's mitt, but my dad wouldn't get it for me. So I held my breath until I passed

Re: autoboxing in 1.3 RC-0

2011-09-15 Thread pmbauer
I ran into this exact issue on an alioth benchmark. Adding the explicit (long ...) conversion gets rid of the reflection warning, but didn't have a significant effect on performance. The inner loop is still boxing the return value. On Thursday, September 15, 2011 8:36:53 AM UTC-7, Sean Corfield

Re: autoboxing in 1.3 RC-0

2011-09-15 Thread pmbauer
see https://github.com/clojure/test.benchmark/blob/master/src/main/clojure/alioth/mandelbrot.clj#L49 There's two ways to get rid of the reflection warning: 1) another function, appropriately type hinted 2) explicit conversion to long According to my measurements for this particular case, option

Re: ClojureScript auto-recompile option

2011-09-15 Thread Chris Granger
FWIW there's also cljs-watch: http://github.com/ibdknox/cljs-watch On Sep 15, 6:35 am, Stuart Campbell stu...@harto.org wrote: Hello, I've written a small hack for the ClojureScript compiler that is useful for working with static HTML projects. When invoked with the :watch option, the cljsc