Re: core.async

2013-06-29 Thread Philip Potter
Looks awesome! I've just taken a moment to think of all the possibilities this could allow. One question: can multiple concurrent IoC threads be multiplexed over multiple JVM threads? One advantage go's goroutines have is that they work fine for single-thread concurrency, but if more cores are ava

Re: core.async

2013-06-29 Thread Thomas Heller
Hey, this looks very interesting. However I'm a little concerned about the semantics of >! and https://gist.github.com/thheller/5890363 (ns thheller.async-test (:use clojure.test) (:require [clojure.core.async :as async :refer (go >! !! ! reply-to reply) (recur (inc work-done))

Re: core.async

2013-06-29 Thread Peter Taoussanis
Oh man, how is everyone _not_ running around screaming about this right now? It seems to me that the Clojure space suffers from an unusual malady: it's busy sitting here quietly advancing half of applied computer science, and no one seems to notice the full extent of its import. Man, I'm som

Re: core.async

2013-06-29 Thread Baishampayan Ghose
On Sat, Jun 29, 2013 at 4:37 PM, Peter Taoussanis wrote: > I honestly feel like I'm witnessing history being made. We all are. -BG -- Baishampayan Ghose b.ghose at gmail.com -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group

Re: multiline strings and multiline comments ?

2013-06-29 Thread Daniel Kwiecinski
(clojure.string/join "\n" [ "this" "is" "multiline" "sting" ]) ;produces "this\nis\nmultiline\nsting" ;) On Monday, 16 August 2010 08:34:03 UTC+1, faenvie wrote: > > hi clojure-users, > > i wonder what the reason is, that clojure(-reader) > does not allow > > 1.

Timing expressions and comparing results

2013-06-29 Thread Frantisek Sodomka
Hi all, If you need to compare running times of different expressions, you could use 'timings' macro: https://gist.github.com/fsodomka/5890711 It takes the number of runs and expressions to time. For example: user=> (timings 1e7 (+ 1 2 3 4) (+ 1 (+ 2 (+ 3 4 [{:time 55.028223, :expr (+ 1 2 3

Tortoise-hare algorithm

2013-06-29 Thread Zhemin Lin
Hi. One of my colleagues gave a share about the cycle detecting tortoise-hare algorithm (wiki ). I translated the script on Wiki from Python to Clojure. It worked, but not elegant. I'd like to make it more functional, more tasty. An

Re: Is there a better way to update a map atom?

2013-06-29 Thread John D. Hume
It's worth knowing that the "moment" is implemented via a compare-and-set, and if the value has been changed (by another thread), the fn you passed to swap! will be called again with the atom's new value. On Jun 28, 2013 11:57 PM, "Greg" wrote: > OK, I've found something that shows how these two

Re: multiline strings and multiline comments ?

2013-06-29 Thread Niels van Klaveren
In my version of CCW CTRL-/ multiline (un)commenting just works (under Windows). Perhaps it's a keyboard shortcut problem ? Only problem there is when multiple lines are selected, and some are uncommented, uncommenting the whole block doesn't work. On Wednesday, August 18, 2010 10:40:39 AM UTC+

Re: core.async

2013-06-29 Thread Jim - FooBar();
On 29/06/13 12:07, Peter Taoussanis wrote: I honestly feel like I'm witnessing history being made. Thank you Rich Hickey, and everyone else in this community for making my work every day so enjoyable. +100! that makes 2 of us :) Thanks indeed Rich (and everyone else of course)... Jim --

question about java 'finalizers' (Charlie's Hunt talk)

2013-06-29 Thread Jim - FooBar();
Hi all, I just finished watching this ( http://www.infoq.com/presentations/jvm-tuning?utm_source=infoq&utm_medium=videos_homepage&utm_campaign=videos_row1) and I'm not sure I understood everything and specifically what he said about finalizers. I noticed that Stuart Sierra (yes, I recognise hi

Re: core.async

2013-06-29 Thread JeremyS
Hi guys, Some time ago I was thinking how nice it would be to have Clojure on top of Go to be able to use channels and goroutines... Well, I stand corrected, we don't need Go, it is now done as a library ! Clojure is a golden inspiration mine, every time something new arrives, if I am not runni

Re: core.async

2013-06-29 Thread David Nolen
Only experience will tell if setTimeout is a problem. I doubt it. I've toyed around with a queueing dispatcher that waits till we get 32 events with flush after 6ms (the time span between which mouse events may arrive under OS X). This permits queueing and dispatching a million events in less than

Re: Tortoise-hare algorithm

2013-06-29 Thread Simone Mosciatti
It is very interesting, just a friendly suggestion, if you share code, and need some help, make sure people can get immediately what is going on. (READ: comment the code) On Saturday, June 29, 2013 1:34:57 PM UTC+2, Zhemin Lin wrote: > > Hi. > One of my colleagues gave a share about the cycle det

Suggested 'server' for hosting clojure web app

2013-06-29 Thread Ravindra Jaju
I want to deploy a small web app - serving mostly static content. I'm using Luminus (http://www.luminusweb.net/) - which is quite neat in the way it builds itself from well-known components. I'm having trouble deciding how to deploy it. I want some automation while deploying upgrades, and would li

Re: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Ravindra Jaju
Oops - I meant to sent this to our local clojure group. But thankfully, it still went to a relevant group rather than a completely wrong one! On Sat, Jun 29, 2013 at 8:17 PM, Ravindra Jaju wrote: > I want to deploy a small web app - serving mostly static content. I'm > using Luminus (http://www

Re: core.async

2013-06-29 Thread Ben Wolfson
So how does all this compare to lamina? On Sat, Jun 29, 2013 at 4:07 AM, Peter Taoussanis wrote: > Oh man, how is everyone _not_ running around screaming about this right > now? > > It seems to me that the Clojure space suffers from an unusual malady: it's > busy sitting here quietly advancing h

Re: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Daniel Pittman
On Sat, Jun 29, 2013 at 7:47 AM, Ravindra Jaju wrote: > I want to deploy a small web app - serving mostly static content. I'm using > Luminus (http://www.luminusweb.net/) - which is quite neat in the way it > builds itself from well-known components. > > I'm having trouble deciding how to deploy i

Re: core.async

2013-06-29 Thread Rich Hickey
On Saturday, June 29, 2013 1:32:26 AM UTC-4, Brandon Bloom wrote: > > > CSP proper is amenable to certain kinds of automated correctness > analysis. > > No work has been done on that front for core.async as yet. > > Although a far cry from Go's race > detector

Re: core.async

2013-06-29 Thread Rich Hickey
On Saturday, June 29, 2013 5:16:55 AM UTC-4, Thomas Heller wrote: > > Hey, > > this looks very interesting. However I'm a little concerned about the > semantics of >! and > https://gist.github.com/thheller/5890363 > > (ns thheller.async-test > (:use clojure.test) > (:require [clojure.core.a

[ANN] Edgar: A basic tool for performing Technical Analysis on financial instruments

2013-06-29 Thread Timothy Washington
Edgar is a basic tool for performing Technical Analysis on financial instruments. This tool is predicated on the presence of high price movements of stock. So far, the emphasis is on: - stock market trading - algorthmic, automated trading - using the In

Re: core.async

2013-06-29 Thread Joseph Smith
> It seems to me that the Clojure space suffers from an unusual malady: it's > busy sitting here quietly advancing half of applied computer science, and no > one seems to notice the full extent of its import. > And it makes me sound like a broken record with my colleagues: "Oh! Clojure has..."

Re: Suggested 'server' for hosting clojure web app

2013-06-29 Thread James Reeves
If you just want to deploy your application, and don't particularly care about having control over your system architecture, you might want to consider a platform like Heroku. Otherwise, a common solution, and one I'd personally recommend, is to have a standalone app executed via Upstart, running

[ANN] byte-streams: a rosetta stone for all the byte representations the jvm has to offer

2013-06-29 Thread Zach Tellman
I've recently been trying to pull out useful pieces from some of my more monolithic libraries. The most recent result is 'byte-streams' [1], a library that figures how how to convert between different byte representations (including character streams), and how to efficiently transfer bytes bet

Re: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Ravindra Jaju
Thank you Daniel and James. I appreciate the detailed response and advice. I'll make myself more clear and specify what I have in mind. I don't want hot-deploys, for sure. :) I erred when I mentioned "without restarting" - that certainly changes quite a few things! Here's what I have in mind for

Re: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Baishampayan Ghose
Pick http-kit, create a uberjar with lein and deploy via Upstart etc. It works like a charm. Jetty is quite good too. ~BG Sent from phone. Please excuse brevity. On 29 Jun 2013 20:17, "Ravindra Jaju" wrote: > I want to deploy a small web app - serving mostly static content. I'm > using Luminus (

Re: lein repl and missing yank

2013-06-29 Thread Cedric Greevey
OTOH, your readline can't handle inserting text you've just copied in some other application, such as copy snippet from web browser window (e.g. Clojuredocs example) and paste in REPL. Using the system-wide copy and paste has clear advantages over using an application-internal one. I'm sure I copy

Re: Is there a better way to update a map atom?

2013-06-29 Thread Cedric Greevey
As nobody else has said this, it bears making explicit that: * swap! is for when the new value depends, in some way, on the previous value. * reset! is for when the new value is independent of the previous value. If you're simply setting a flag, for example, (reset! foo true) works. If you're in

Re: question about java 'finalizers' (Charlie's Hunt talk)

2013-06-29 Thread Cedric Greevey
On Sat, Jun 29, 2013 at 8:41 AM, Jim - FooBar(); wrote: > Hi all, > > I just finished watching this ( > http://www.infoq.com/presentations/jvm-tuning?utm_source=infoq&utm_medium=videos_homepage&utm_campaign=videos_row1 > ) > and I'm not sure I understood everything and specifically what he said >

Re: core.async

2013-06-29 Thread David Pollak
What's the entry in project.clj to use the core.async stuff? Thanks! On Sat, Jun 29, 2013 at 9:44 AM, Joseph Smith wrote: > It seems to me that the Clojure space suffers from an unusual malady: it's > busy sitting here quietly advancing half of applied computer science, and > no one seems to n

Re: Tortoise-hare algorithm

2013-06-29 Thread Cedric Greevey
If the function is expensive to compute, you might prefer Brent's periodicity detection algorithm, which instead of 1.5xn invocations of the function only requires n + o(log n) invocations and supposedly detects just as fast. You store [last-n, last-f, next-n] = [0, f(0), 1] and then, for n = 1 to

Re: core.async

2013-06-29 Thread Brandon Bloom
I don't think it's published to a maven repository yet. You can check it out, install it with `lein install`, then depend on it via [core.async "0.1.0-SNAPSHOT"] On Sat, Jun 29, 2013 at 2:50 PM, David Pollak wrote: > What's the entry in project.clj to use the core.async stuff? > > Thanks! > > >

Re: core.async

2013-06-29 Thread Cedric Greevey
On Sat, Jun 29, 2013 at 7:07 AM, Peter Taoussanis wrote: > Oh man, how is everyone _not_ running around screaming about this right > now? > > It seems to me that the Clojure space suffers from an unusual malady: it's > busy sitting here quietly advancing half of applied computer science, and > no

Re: Suggested 'server' for hosting clojure web app

2013-06-29 Thread James Reeves
On 29 June 2013 18:59, Ravindra Jaju wrote: > 1] Upstart is good - so, I will need to figure out the equivalent on > Fedora (which is what I use - primarily because I'm too familiar with it > and have been an RH/Fedora guy since about ~1995). Essentially, a daemon > monitor which will restart in

Re: Clojure generates unnecessary and slow type-checks

2013-06-29 Thread Jason Wolfe
This looks very interesting, thanks for sharing! I'll think about it a bit while working on our codebase and see if I can contribute any good examples. On Fri, Jun 28, 2013 at 7:17 AM, Mikera wrote: > On Thursday, 20 June 2013 08:45:47 UTC+1, Jason Wolfe wrote: >> >> On Saturday, June 15, 2013

Re: core.async

2013-06-29 Thread Jozef Wagner
This is great news! Especially that it is designed also to support other hosts besides JVM. BTW how do IOC threads compare (e.g. in performance and ability to use ForkJoinPool) to coroutines such as those in pulsar? [1] [2] [1] http://blog.paralleluniverse.co/post/49445260575/quasar-pulsar [2]

Re: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Maciej Mazur
On Sat, 29 Jun 2013 21:31:22 +0100, James Reeves wrote: > On 29 June 2013 18:59, Ravindra Jaju wrote: > >> 1] Upstart is good - so, I will need to figure out the equivalent on >> Fedora (which is what I use - primarily because I'm too familiar with >> it and have been an RH/Fedora guy since abou

Re: Suggested 'server' for hosting clojure web app

2013-06-29 Thread James Reeves
On 30 June 2013 00:12, Maciej Mazur wrote: > On Sat, 29 Jun 2013 21:31:22 +0100, James Reeves wrote: > > > Since Fedora 9, Upstart has been the default on that as well, so you're > > in luck :) > > Actually Upstart has been replaced by systemd since Fedora 15 > > Oops! Sorry for the misinformatio

Re: Is there a better way to update a map atom?

2013-06-29 Thread Brandon Bloom
> Can anyone explain the relationship between swap! and reset! ? swap! is for "CAS" See: http://en.wikipedia.org/wiki/Compare-and-swap In the examples here, you're fully replacing a value, so reset! is fine... assuming that the replacement value was not derived from the existing value. If the

Help deciphering ArityException message

2013-06-29 Thread Dave Kincaid
Could someone help me decipher the ArityException I'm getting. It's not making sense to me. First here is the exception: ArityException Wrong number of args (1) passed to: lastN$reformat-headers$fn clojure.lang.AFn.throwArity (AFn.java:437) and here is the function reformat-headers: (defn ref

UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
I'm using pprint to write out a map to a file then trying to read it back in using clojure.edn/read (I also get the same error using read). Here is the output (it's a map that was created by the Langohr rabbitmq library): {:header {:timestamp #inst "2058-04-07T17:56:17.000-00:00", :delivery

Re: Is there a better way to update a map atom?

2013-06-29 Thread Ben Wolfson
On Sat, Jun 29, 2013 at 5:07 PM, Brandon Bloom wrote: > > Can anyone explain the relationship between swap! and reset! ? > > swap! is for "CAS" > > See: http://en.wikipedia.org/wiki/Compare-and-swap > > How so? No comparison is done (unless it's done in the supplied function, which is entirely up

Re: Is there a better way to update a map atom?

2013-06-29 Thread Ben Wolfson
anyway the relationship between swap! and reset! is that (reset! atom newval) === (swap! atom (constantly newval)). (Though that isn't how reset! is implemented.) On Sat, Jun 29, 2013 at 5:21 PM, Ben Wolfson wrote: > On Sat, Jun 29, 2013 at 5:07 PM, Brandon Bloom > wrote: > >> > Can anyone exp

Re: Is there a better way to update a map atom?

2013-06-29 Thread Cedric Greevey
On Sat, Jun 29, 2013 at 8:21 PM, Ben Wolfson wrote: > On Sat, Jun 29, 2013 at 5:07 PM, Brandon Bloom > wrote: > >> > Can anyone explain the relationship between swap! and reset! ? >> >> swap! is for "CAS" >> >> See: http://en.wikipedia.org/wiki/Compare-and-swap >> >> > How so? No comparison is d

Re: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Nick Gonzalez
I'm a big fan of http-kit. Lightweight, easy to use, and responsive. -- -- 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

Re: Is there a better way to update a map atom?

2013-06-29 Thread Ben Wolfson
On Sat, Jun 29, 2013 at 5:27 PM, Cedric Greevey wrote: > > On Sat, Jun 29, 2013 at 8:21 PM, Ben Wolfson wrote: > >> On Sat, Jun 29, 2013 at 5:07 PM, Brandon Bloom > > wrote: >> >>> > Can anyone explain the relationship between swap! and reset! ? >>> >>> swap! is for "CAS" >>> >>> See: http://en

Re: Is there a better way to update a map atom?

2013-06-29 Thread Cedric Greevey
Who said swap *was* CAS, rather than was implemented *in terms of* CAS? In any event, your claim that "no comparison is done unless it's done in the supplied function" is just plain wrong. Comparison *is* done, outside that function, to make sure the atom wasn't changed by another thread while the

Re: Help deciphering ArityException message

2013-06-29 Thread Baishampayan Ghose
This should work. What does headers look like? Sometimes the #(...) reader form can cause problems. Does using the (fn ...) form help? ~BG On Sun, Jun 30, 2013 at 5:39 AM, Dave Kincaid wrote: > Could someone help me decipher the ArityException I'm getting. It's not > making sense to me. First her

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
Adding a method to the `print-dup` multimethod that dispatches on ByteArrayLongString should help. See here for an example - http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid wrote: > I'm using pprint to write out a map to a file then try

Re: Help deciphering ArityException message

2013-06-29 Thread Dave Kincaid
Here is the whole thing: (defn reformat-headers [headers] (debug (str "Reformatting " headers)) (map #(hash-map [%1 0] (.toString [%2 1])) headers)) (defn spit-messages "Write out the messages in the given seq." [messages dest] (pprint (for [[metadata ^bytes payload] messages]

Re: Is there a better way to update a map atom?

2013-06-29 Thread Ben Wolfson
On Sat, Jun 29, 2013 at 6:06 PM, Cedric Greevey wrote: > Who said swap *was* CAS, rather than was implemented *in terms of* CAS? In > any event, your claim that "no comparison is done unless it's done in the > supplied function" is just plain wrong. Comparison *is* done, outside that > function,

Re: Is there a better way to update a map atom?

2013-06-29 Thread Brandon Bloom
Could we please curb the pedantry? On Sat, Jun 29, 2013 at 9:21 PM, Ben Wolfson wrote: > On Sat, Jun 29, 2013 at 6:06 PM, Cedric Greevey wrote: > >> Who said swap *was* CAS, rather than was implemented *in terms of* CAS? >> In any event, your claim that "no comparison is done unless it's done in

Re: Help deciphering ArityException message

2013-06-29 Thread Baishampayan Ghose
What is the shape of `headers`? It looks like headers is a sequence of two-element sequences, in which case `reformat-headers` should be something like this - (defn reformat-headers [headers] (map (fn [[x y]] (hash-map [x 0] (.toString [y 1]))) headers)) ;; note the destructuring.

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
Thanks! If that works, it is perfect. However, my first attempt isn't making any difference. Here is what I have: (defmethod print-dup com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString [o w] (print-ctor o (fn [o w] (print-dup (String. (.getBytes o)) w)) w)) (defn spit-messages "

Re: Help deciphering ArityException message

2013-06-29 Thread Dave Kincaid
Yes! That does help. It's complaining about the arity of the function in the map, not the reformat-headers function. Now I understand. Thank you very much for helping clarify it for me. Dave On Saturday, June 29, 2013 8:30:21 PM UTC-5, Baishampayan Ghose wrote: > > What is the shape of `headers

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
Does this work? ;; do the defmethod extension as usual and then define spit-messages as such (defn spit-messages "Write out the messages in the given seq." [messages dest] (binding [*print-dup* true] (pprint (for [[metadata ^bytes payload] messages] {:header metadata :payload

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
Hmm. No, it doesn't. This is what I get with pprint by itself: :headers {"pluginKey" #} with your version I get: :headers #=(java.util.HashMap. {"pluginKey" #=(com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString. "PLUGIN2")}) what I think I needs to be able to read it back in is:

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
This form, by the way is readable. Not sure why the print-dup extension is not working though... ~BG On Sun, Jun 30, 2013 at 7:18 AM, Dave Kincaid wrote: > Hmm. No, it doesn't. This is what I get with pprint by itself: > > :headers {"pluginKey" #} > > with your version I get: > > :headers >#=

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
By the way, there is also the print-method multimethod which might just do the trick for you. Just try this one with your original version of `spit-messages` - http://clojuredocs.org/clojure_core/clojure.core/print-method ~BG On Sun, Jun 30, 2013 at 7:18 AM, Dave Kincaid wrote: > Hmm. No, it does

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
Thank you very much for the help. I really appreciate you trying. I don't know what is going on, but I need to move on from this. Dave On Saturday, June 29, 2013 8:57:31 PM UTC-5, Baishampayan Ghose wrote: > > This form, by the way is readable. Not sure why the print-dup > extension is not work

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
Readable by clojure.edn/read? I get this exception from it: RuntimeException No dispatch macro for: = clojure.lang.Util.runtimeException (Util.java:219) I think I'm going to give up on this and serialize it to JSON. Should be easier. On Saturday, June 29, 2013 8:57:31 PM UTC-5, Baishampayan G

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
No problem, but I am sure someone else on this group will have the answer :) ~BG On Sun, Jun 30, 2013 at 7:33 AM, Dave Kincaid wrote: > Thank you very much for the help. I really appreciate you trying. I don't > know what is going on, but I need to move on from this. > > Dave > > > On Saturday, J

Re: Is there a better way to update a map atom?

2013-06-29 Thread Cedric Greevey
On Sat, Jun 29, 2013 at 9:21 PM, Ben Wolfson wrote: > On Sat, Jun 29, 2013 at 6:06 PM, Cedric Greevey wrote: > >> Who said swap *was* CAS, rather than was implemented *in terms of* CAS? >> In any event, your claim that "no comparison is done unless it's done in >> the supplied function" is just p

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
That works perfectly! Thank you again very much. On Saturday, June 29, 2013 9:01:32 PM UTC-5, Baishampayan Ghose wrote: > > By the way, there is also the print-method multimethod which might > just do the trick for you. Just try this one with your original > version of `spit-messages` - > http:

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
Cool! ~BG On Sun, Jun 30, 2013 at 7:49 AM, Dave Kincaid wrote: > That works perfectly! Thank you again very much. > > > On Saturday, June 29, 2013 9:01:32 PM UTC-5, Baishampayan Ghose wrote: >> >> By the way, there is also the print-method multimethod which might >> just do the trick for you. Jus

Re: Tortoise-hare algorithm

2013-06-29 Thread Zhemin Lin
Hi Simone & Cedric, Thanks for your comment. In fact, my purpose is to demonstrate to my colleagues how Clojure deals with this algorithm. I'm going to implement the Brent's way. However, I'm wondering if I can make the Floyd's more functional. Tail recursion is good, but not good enough to sho