Re: Newbie: adding items to a global vector in doseq

2014-08-14 Thread Tassilo Horn
phi...@free.fr writes: > I have read up on atoms and used swap! to set the urls2 vector atom in > my code. Thanks. > > One problem remains though: I can't retrieve the atom vector's items > > *(nth urls 10)* > > throws the following exception > > java.lang.UnsupportedOperationException: nth not su

Re: Strange behavior with alts! and :default in core async

2014-08-14 Thread dgrnbrg
You're all right--that was a cut & paste error. I meant that I see this behavior with alt!!, not alts! On Thursday, August 14, 2014 3:31:45 PM UTC-4, Ghadi Shayban wrote: > > What Daniel said. The call is incorrect, its args are alt-shaped, but it > calls alt*s*. > > alt is the macro that is sh

Re: Newbie: adding items to a global vector in doseq

2014-08-14 Thread Mike Fikes
Thomas is absolutely right, Philippe. Things also get easier if you avoid, or defer side effects, and first focus on pure functions. So, for example at the REPL, you might first try processing a literal sequence of lines, repeatedly adjusting the processing code, tweaking the regex, until you

Re: Newbie: adding items to a global vector in doseq

2014-08-14 Thread Thomas Heller
Hey, it's not how you'd usually do things in Clojure and I'd consider the use of an atom in this place as "wrong". I was struggling with Clojure in the beginning too and my code looked pretty much like yours, but the faster you get into the Clojure mindset the easier it will be. This might be

Re: Strange behavior with alts! and :default in core async

2014-08-14 Thread Ghadi Shayban
What Daniel said. The call is incorrect, its args are alt-shaped, but it calls alt*s*. alt is the macro that is shaped like cond. alts is the function that takes a vector Both take splatted options at the end. Can never use single bang* except within go.* go => ! thread => !! Unfortunately i

Re: Strange behavior with alts! and :default in core async

2014-08-14 Thread Eric Normand
Hi there, The :default option is for a *value* that should be returned if none of the channels are available. The expression is evaluated *before* the async/alts! call happens (just like normal parameters). I think you are misunderstanding alts!. It should be used like this (let [[val ch] (asy

Re: Newbie: adding items to a global vector in doseq

2014-08-14 Thread phiroc
Just solved the problem by prepending at at-sign, in both cases: ( *nth @urls 10)(doseq [x @urls] (println x))* Le jeudi 14 août 2014 18:05:25 UTC+2, phi...@free.fr a écrit : > > > Hello, > > I am trying to add URLs contained in a text file (eg. apple.com, > ibm.com...), to a global vector

Re: Newbie: adding items to a global vector in doseq

2014-08-14 Thread phiroc
Hi Mike, I have read up on atoms and used swap! to set the urls2 vector atom in my code. Thanks. One problem remains though: I can't retrieve the atom vector's items *(nth urls 10)* throws the following exception java.lang.UnsupportedOperationException: nth not supported on this type: Atom

Newbie: adding items to a global vector in doseq

2014-08-14 Thread Mike Fikes
Read up on atoms. The results of your conj call are being discarded. For example, check out the behavior of this: (def urls2 (atom [])) (swap! urls2 conj "http://foo.bar";) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: Strange behavior with alts! and :default in core async

2014-08-14 Thread Daniel Solano Gómez
Hello, I was just wondering if you are using the right function. Without actually trying to run any code, a couple of things pop into mind: 1. alts! can only be used in a go macro. 2. The invocation doesn't look right for alts!. Perhaps you want something like: (let [[val port] (async/alts!! [

Re: [ANN] Envvar 1.1.0 — a library for handling environment variables

2014-08-14 Thread Constantine Vetoshev
On Thursday, August 14, 2014 2:53:30 AM UTC-7, Tony Tam wrote: > > It wasn't really clear to me from the README why use this instead of > environ. Care to explain a little more in detail? I.e. give a concrete use > case. > Any particular reason for not supporting .lein-env files? > Also, if a .en

Newbie: adding items to a global vector in doseq

2014-08-14 Thread phiroc
Hello, I am trying to add URLs contained in a text file (eg. apple.com, ibm.com...), to a global vector called url2, but to no avail, the vector remains empty. Any suggestions would be greatly appreciated. Many thanks. Philippe (def fich "data.txt") > > (def urls2 (vec nil)) > > (def

Re: [ANN] Envvar 1.1.0 — a library for handling environment variables

2014-08-14 Thread Constantine Vetoshev
On Thursday, August 14, 2014 6:46:56 AM UTC-7, James Reeves wrote: > > You can do this with Environ. Leiningen checks for a profiles.clj in your > project directory, as well as then one in $HOME/.lein. If you add > profiles.clj to your .gitignore file, you can use it for local overrides > during

Strange behavior with alts! and :default in core async

2014-08-14 Thread dgrnbrg
When I use alts!, it seems that both the put and :default action run every time. I've included the code sample below: (let [inner-chan (async/chan (async/buffer 1000)) mult (async/mult inner-chan) (async/thread (while true (let [e (.take linked-blocking-queue)] (async/al

Re: running a jar-based cli tool

2014-08-14 Thread Brian Craft
On Wednesday, August 13, 2014 11:30:59 PM UTC-7, Shantanu Kumar wrote: > > > > On Thursday, 14 August 2014 03:25:48 UTC+5:30, Brian Craft wrote: >> >> Thanks! This works perfectly. >> >> It took a few tries to find the right incantation, but this seems to do: >> >> (defn -main [& args] >> (Main

Clojure developers wanted redux

2014-08-14 Thread Denis McCarthy
Posted here a few months and received a good response, so here goes again! Aviso is looking for Clojure developers to work on Novate, our Electronic Funds Transfer (EFT) payments switch. When it's at home, an EFT payments switch is responsible for providing connectivity for real-time messaging be

Re: [ANN] Envvar 1.1.0 — a library for handling environment variables

2014-08-14 Thread James Reeves
On 13 August 2014 19:10, Constantine Vetoshev wrote: > The JVM does not make using environment variables easy or convenient. The > environ library took a step in > the right direction by abstracting away the distinction between environment > variables and

Re: Transducers are Coming

2014-08-14 Thread Jozef Wagner
This is not safe usage, as you are not calling the 'flushing' method or handle reduced objects. Correct use would be (def xform (comp (filter odd?) (map #(* % % (def strip-reduced [x] (if (reduced? x) @x x)) (let [r (xform conj)] (strip-reduced (r (strip-reduced (r #{1 2 3} 7) ;=> #{1 3 2

Re: Transducers are Coming

2014-08-14 Thread vvedee
Some alternate transducers usage: (def xform (comp (filter odd?) (map #(* % % ((xform conj) #{1 2 3} 7) ;=> #{1 3 2 49} ((xform conj) [1 2 3] 6) ;=> [1 2 3] -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clo

Re: [ANN] Envvar 1.1.0 — a library for handling environment variables

2014-08-14 Thread Tony Tam
It wasn't really clear to me from the README why use this instead of environ. Care to explain a little more in detail? I.e. give a concrete use case. Any particular reason for not supporting .lein-env files? Also, if a .env is just a java .properties file, then why use .env files? Thanks. On We

Re: FYI: for Clojure people stuck with some Java, use DCEVM

2014-08-14 Thread henry w
We have actually installed DCEVM into Oracle jdk's 6 and 7 because those were what we are currently using. That all seems to work fine for us so far. The approach I have taken with calling clojure from java is to create a couple of clojure records which implement java interfaces. In the java co

BOB 2015 - Call for Contributions (Berlin, Germany, January 23, 2015)

2014-08-14 Thread Michael Sperber
BOB has a strong focus on functional programming, so Clojure submissions are very welcome! BOB Conference 2015 Berlin 23.1.2015 http://bobkonf.de/2015/ CALL FOR CO