data.priority-map 0.0.1

2011-12-16 Thread Sunil S Nandihalli
Hi, The data.priority-map has been a nice library. I have used it quiet often. Recently, when I used it, I discovered the following unexpected behaviour.. can somebody throw some light on it? (- (pm/priority-map-by #( (count %1) (count %2))) (update-in [1] #(assoc (or % {}) 2 3))

Re: data.priority-map 0.0.1

2011-12-16 Thread Sunil S Nandihalli
The project file I used .. (defproject trybug 1.0.0-SNAPSHOT :description FIXME: write description :dependencies [[org.clojure/clojure 1.3.0] [org.clojure/data.priority-map 0.0.1]] :repositories {sonatype-oss-public

Re: How to: convert output stream into an input stream

2011-12-16 Thread Shantanu Kumar
On Dec 16, 2:01 am, Trevor tcr1...@gmail.com wrote: I have created an output  stream, which appears to work fine, however I get an error when trying to convert the output stream into an input stream for use in ring: ('use [clojure.java.io :only [input-stream]]) = (with-out-str (ofn var))

Re: How to: convert output stream into an input stream

2011-12-16 Thread Alan Malloy
You can't really do this in a single thread without risking blocking. But with another thread, it's fairly simple. For example, I do this in my gzip-middleware, copying an InputStream through a pipe with GZIP wrapping:

Re: Bug with 1.3 primitive function return value hinting.

2011-12-16 Thread Meikel Brandmeyer
Hi, Am 16.12.2011 um 01:58 schrieb Cedric Greevey: I know that every fn is a class; I am questioning the very need for prim interfaces. If you don't have an interface, you can't redef the function at runtime. Since the class of the function changes, you'll have the call sites wired to the

Re: How to: convert output stream into an input stream

2011-12-16 Thread Alan Malloy
Edit: you should probably use with-open at some point, to make sure you close the output writer. I copied pretty badly from my own example :P. So more like: (let [pipe-in (PipedInputStream.)] (future; new thread to prevent blocking deadlock (with-open [out (- pipe-in

Re: data.priority-map 0.0.1

2011-12-16 Thread Mark Engelberg
priority-map-by is going to do funky things if your ordering function does not obey the trichotomy property (i.e., for all a, b, exactly one of ab, a=b, or ab holds). The reason for this is that priority-map internally uses Clojure's sorted-map, and Clojure's sorted-map does funky things if the

Re: Bug with 1.3 primitive function return value hinting.

2011-12-16 Thread Cedric Greevey
On Fri, Dec 16, 2011 at 4:51 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 16.12.2011 um 01:58 schrieb Cedric Greevey: I know that every fn is a class; I am questioning the very need for prim interfaces. If you don't have an interface, you can't redef the function at runtime. You

Re: data.priority-map 0.0.1

2011-12-16 Thread Sunil S Nandihalli
Thanks Mark, for your response... While I understand what you are saying.. I don't understand as to why the following is working .. (assoc (pm/priority-map 1 1 2 1) 3 1) gives {1 1 2 1 3 1} Am I not supposed to be using this? will it eventually bite me? Sunil. On Fri, Dec 16, 2011 at 3:48 PM,

Re: Bug with 1.3 primitive function return value hinting.

2011-12-16 Thread Meikel Brandmeyer
Hi, Am 16.12.2011 um 12:17 schrieb Cedric Greevey: You *already* can't change the type signature of an optimized function without needing to recompile its callers. But once you settled on a type signature, you have the usual fast benchmark,optimize,reload-cycle. Without interfaces you don't

Potential issue with clojure 1.3 and build of 1.4 master from 13/12 or perhaps just my lack of understanding !

2011-12-16 Thread Graham Berks
Hi, learning clojure so this may just be a lack of understanding on my part. Been looking at a post about swing and clojure and it used an agent to implement a flipper with code below. When I run the code in clojure 1.2.1 via (def flipper (new-flipper)) (send flipper start) all is fine and the

Issue using agent under 1.3 and 1.4-snapshot or perhaps just my lack of understanding

2011-12-16 Thread Graham
Hi, learning clojure and came across some code discussing swing and a code for a flipper as below (defn new-flipper [] (agent {:total 0, :heads 0, :running false, :random (java.util.Random.)})) (defn calculate [state] (if (:running state) (do (send *agent*

Re: want to make a 'debug' function, how to get current source and line number?

2011-12-16 Thread Narvius
(defmacro dbg [x] `(let [x# ~x] (println (str *file* :) [ '~x = x# ]) x#)) I personally use this macro. It shows only the file name (I can't find out how to get the current line number). This one has the advantage of still returning the same value as the expression itself. On Dec 15,

Re: Clojure videos no longer downloadable

2011-12-16 Thread Matt Freeman
Here's an idea. Put the videos on a site that has the best CDN reach (especially noticeable in Asia), does automatic transcoding to lower resolutions, and most importantly can jump to any point in the videos. Works on android, ipod, wp7, and even blackberry. Youve probably not heard of it,

Re: ANNOUNCEMENT: core.cache version 0.5.0

2011-12-16 Thread Qihui Sun
Are it going to support JCache JSR? 2011/12/13 Fogus mefo...@gmail.com core.cache v0.5.0 Release Notes === core.cache is a new Clojure contrib library providing the following features: * An underlying `CacheProtocol` used as the base abstraction for

lazy-seq and recursion.

2011-12-16 Thread Narvius
Hello, I just read some of the clojure.core source, and when reading map and range, I noticed that inside lazy-seq, recursion doesn't seem to stack overflow. I then tried it myself on some trivial examples, and indeed, I can take hundreds of thousands of entries from such a list without anything

Re: want to make a 'debug' function, how to get current source and line number?

2011-12-16 Thread Narvius
(defmacro dbg [x] `(let [x# ~x] (println (str *file* :) [ '~x = x# ]) x#)) Without the line number, because I don't know how to retrieve (neither could I find anything on it). On Dec 15, 6:48 am, jaime xiejianm...@gmail.com wrote: Hello there, I want to write a function named debug

clojurescript: how do i copy one input text field to another?

2011-12-16 Thread bob
I new to clojurescript and i thought i would take a simple example like http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onclick it has javascript that does the following: button onclick=document.getElementById('field2').value=document.getElementById('field1').valueCopy Text/button i

Re: bug in clojure.walk in 1.3

2011-12-16 Thread Stuart Sierra
Please create a JIRA ticket for adding 'empty' support to `bean`. -S -- 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 moderated - please be patient with

Re: Potential issue with clojure 1.3 and build of 1.4 master from 13/12 or perhaps just my lack of understanding !

2011-12-16 Thread Stuart Sierra
This is a problem with a feature introduced in 1.3: binding-conveyance for Agent sends. Starting in 1.3, agent actions are called with the same thread-local Var bindings that were in effect when they were called. In some situations, this can build up a stack of thread-local Var binding frames,

Re: bug in clojure.walk in 1.3

2011-12-16 Thread Joost
On Dec 13, 8:38 pm, Alan Malloy a...@malloys.org wrote: Issue is in bean, not walk. walk calls (empty foo) on its collection, in order to make sure you get back a collection of the same type. bean maps are, I guess, some special type rather than an ordinary c.l.PersistentHashMap; and that type

Re: Potential issue with clojure 1.3 and build of 1.4 master from 13/12 or perhaps just my lack of understanding !

2011-12-16 Thread Tassilo Horn
Stuart Sierra the.stuart.sie...@gmail.com writes: Hi Stuart, This is a problem with a feature introduced in 1.3: binding-conveyance for Agent sends. Starting in 1.3, agent actions are called with the same thread-local Var bindings that were in effect when they were called. In some

Re: want to make a 'debug' function, how to get current source and line number?

2011-12-16 Thread Brian Marick
On Dec 14, 2011, at 11:48 PM, jaime wrote: I want to write a function named debug which will print out date- time msg + current source-line + etc. info, but I don't know how to get the current source and line number of the running point (just like what REPL does when encounter any exceptions)

Re: lazy-seq and recursion.

2011-12-16 Thread Tassilo Horn
Narvius narv...@gmail.com writes: Hi Narvius, So, my question is, why exactly DOESN'T it crash and burn horribly with the cries of dying bits in the background? I suppose it has something to do with how lazy-seqs work (another mystery for me). A lazy seq is basically a sequence of the first

Re: Potential issue with clojure 1.3 and build of 1.4 master from 13/12 or perhaps just my lack of understanding !

2011-12-16 Thread Stuart Sierra
Tassilo wrote: But shouldn't at least the thread-local Var binding frames be freed after the actions have been performed? Yes. It's a bug. Just created CLJ-898: http://dev.clojure.org/jira/browse/CLJ-898 -S -- You received this message because you are subscribed to the Google Groups Clojure

Re: clojurescript: how do i copy one input text field to another?

2011-12-16 Thread David Nolen
Can you create a paste of your index.html as well as your ClojureScript file? Thanks! David On Thu, Dec 15, 2011 at 5:12 PM, bob rditm...@gmail.com wrote: I new to clojurescript and i thought i would take a simple example like

Re: Issue using agent under 1.3 and 1.4-snapshot or perhaps just my lack of understanding

2011-12-16 Thread Stuart Sierra
Discussed here: https://groups.google.com/forum/#!topic/clojure/1qUNPZv3OYA/discussion -- 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 moderated -

Re: How to: convert output stream into an input stream

2011-12-16 Thread Trevor
This is great. Thanks for the help. On Dec 16, 2:55 am, Alan Malloy a...@malloys.org wrote: Edit: you should probably use with-open at some point, to make sure you close the output writer. I copied pretty badly from my own example :P. So more like: (let [pipe-in (PipedInputStream.)]  

Re: Potential issue with clojure 1.3 and build of 1.4 master from 13/12 or perhaps just my lack of understanding !

2011-12-16 Thread Tassilo Horn
Stuart Sierra the.stuart.sie...@gmail.com writes: Hi Stuart, Tassilo wrote: But shouldn't at least the thread-local Var binding frames be freed after the actions have been performed? Yes. It's a bug. Just created CLJ-898: http://dev.clojure.org/jira/browse/CLJ-898 I've attached a patch to

Re: data.priority-map 0.0.1

2011-12-16 Thread Mark Engelberg
On Fri, Dec 16, 2011 at 9:32 AM, Mark Engelberg mark.engelb...@gmail.com wrote: Or how about something like #(if (= %1 %2) 0 (compare [(count %1) (str %1)] [(count %2) (str %2)])) I retract this particular example. Upon further thought, since maps aren't guaranteed to always stringify the same

Re: want to make a 'debug' function, how to get current source and line number?

2011-12-16 Thread jaime
Thank all of you for the information. I finally picked up an approach of using form and *file*, and here's my code snippet of the function: == (defmacro debug Print debug info. [ variables] (let [datetime 2011-12-17 01:59:37

Re: want to make a 'debug' function, how to get current source and line number?

2011-12-16 Thread jaime
Yes this is a good point, but how can I avoid this blowing up problem if I'm not handling a single variable (just as the code in my last post)? On 12月16日, 上午5时09分, Cedric Greevey cgree...@gmail.com wrote: On Thu, Dec 15, 2011 at 1:54 PM, Alan Malloy a...@malloys.org wrote: This will print all

Re: data.priority-map 0.0.1

2011-12-16 Thread Mark Engelberg
Fleshing out the solution I outlined in a previous email, here's a concrete implementation that lets you use maps as priorities. (defn- make-id-generator [] (let [i (atom 0), generate-unique-id (fn generate-unique-id [item] (swap! i inc))] (memoize generate-unique-id))) (defn-

Can JVM GC be tweaked to quickly reuse memory of objects that soon become garbage?

2011-12-16 Thread Andy Fingerhut
This is a question about Clojure performance on the JVM. There might be similar but different tweaks on the CLR or for ClojureScript, but I'm only curious about those if someone knows how to achieve the desired performance improvements today. I can give more concrete examples if there is

Re: want to make a 'debug' function, how to get current source and line number?

2011-12-16 Thread Cedric Greevey
2011/12/16 jaime xiejianm...@gmail.com: Yes this is a good point, but how can I avoid this blowing up problem if I'm not handling a single variable (just as the code in my last post)? Someone else indicated that just using pr-str and using the *print-length* and *print-level* vars can avoid

Re: want to make a 'debug' function, how to get current source and line number?

2011-12-16 Thread Brian Goslinga
I believe the line number can be found in the metadata on lists that are read in by the reader. -- 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 moderated

Re: Bug with 1.3 primitive function return value hinting.

2011-12-16 Thread Cedric Greevey
On Fri, Dec 16, 2011 at 8:20 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 16.12.2011 um 12:17 schrieb Cedric Greevey: You *already* can't change the type signature of an optimized function without needing to recompile its callers. But once you settled on a type signature, you have the

Re: Can JVM GC be tweaked to quickly reuse memory of objects that soon become garbage?

2011-12-16 Thread Jules
You can tweak the size of the young generation with the -Xmn flag, but setting it very small likely will be worse. That is because (1) you'll have more young GCs and due to the way GC works they are just as expensive as they would be with a large young generation and (2) then more objects will go

Re: Bug with 1.3 primitive function return value hinting.

2011-12-16 Thread Brian Goslinga
On Dec 16, 3:51 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 16.12.2011 um 01:58 schrieb Cedric Greevey: I know that every fn is a class; I am questioning the very need for prim interfaces. If you don't have an interface, you can't redef the function at runtime. Since the class of