Re: interest in STM, where can I start to get knowing well about it?

2011-05-19 Thread MohanR
I was perplexed too but I think most( or all ) of the concurrency features in Clojure is based on java.util.concurrent. I might be wrong about this though. So once you start programming java.util.concurrent you can learn clojure STM. Someone who has more expertise can comment about this. Thanks,

Re: Clojure stack

2011-05-19 Thread Thorsten Wilms
On 05/19/2011 02:06 AM, Sean Corfield wrote: I've actually found the Clojure community to be one of the most welcoming and most helpful of almost any technology that I've picked up in about 30 years. YMMV, I guess, and I'm sure it depends on your programming background. Same here, except 30 ye

Re: interest in STM, where can I start to get knowing well about it?

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 3:13 AM, MohanR wrote: > I was perplexed too but I think most( or all ) of the concurrency > features in Clojure is based on java.util.concurrent. I might be wrong > about this though. Certainly some of them are. Promise/deliver uses CountDownLatch. Atom unsurprisingly is

Re: interest in STM, where can I start to get knowing well about it?

2011-05-19 Thread MohanR
So I think readng the actual STM source with Java' features might help. Are there actually books on this topic ? Peter Van roy's Data flow concurrency book ? Thanks, Mohan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send e

Help: how to construct lazy sequences

2011-05-19 Thread timc
Hello I wonder if I could ask for advice on how to construct a lazy sequence. My application might be of interest to some of you. The context for this is that I have an embedded system with very limited facilities for proper debugging. I have inserted a 'trace' facility in the embedded code that

Aw: Help: how to construct lazy sequences

2011-05-19 Thread Meikel Brandmeyer
Hi, how about this? (def sentence-spec {1 {:n 2 :fmt "[1] a=%d b=%d"} 4 {:n 0 :fmt "[4]"} 5 {:n 1 :fmt "[5] z=%d"}}) (defn input-reader [inputQ eof?] (fn [byteArray] (.put inputQ (or byteArray eof? (defn input-bytes [inputQ eof?] (->> (rep

Re: Help: how to construct lazy sequences

2011-05-19 Thread Jonathan Fischer Friberg
See the source of clojure.contrib.duck-streams/read-lines http://clojuredocs.org/clojure_contrib/clojure.contrib.duck-streams/read-lines For the second question: Use read-lines directly. If you want a lazy-seq that doesn't close the stream when it's empty, ; untested (defn take-bytes [rdr] (

Re: Clojure stack

2011-05-19 Thread Nick Zbinden
I think there are a few things most people agree about: - The people in the comunity are genaraly very nice and help noobs (stackoverflow, irc. mailinglist ...) - Clojure.org has very cool content. - Clojure.org is not a good place for noob So i propose some things that I think would make a bette

What role does ? operator play?

2011-05-19 Thread octopusgrabbus
Given the following function (defn proint-down-from [x] (when (pos? x) (println x) (recur (dec x What role does the ? operator play. It looks like it is creating a variable name. Thanks. -- You received this message because you are subscribed to the Google Groups "Cloju

Re: What role does ? operator play?

2011-05-19 Thread Ambrose Bonnaire-Sergeant
Hi, The ? is merely a convention used to name predicate functions (ie. functions that return true or false). It is not enforced, but clojure.core follows it. It's a good idea to follow it. I think ruby has a similar convention. Thanks, Ambrose On Thu, May 19, 2011 at 9:09 PM, octopusgrabbus wro

Re: What role does ? operator play?

2011-05-19 Thread Alex Robbins
? isn't an operator, it is part of a function's name. user=> (doc pos?) - clojure.core/pos? ([x]) Returns true if num is greater than zero, else false nil user=> Hope that helps! Alex On Thu, May 19, 2011 at 8:09 AM, octopusgrabbus wrote: > Given the following function

Re: What role does ? operator play?

2011-05-19 Thread Timothy Baldridge
> What role does the ? operator play. It looks like it is creating a > variable name. > Thanks. > In clojure (and other languages like Ruby) the ? is not an operator, it's actually part of the function name. Normally ? means that the function returns a boolean. Think of it as asking a question, s

Aw: What role does ? operator play?

2011-05-19 Thread Meikel Brandmeyer
Hi, ? is not an operator, but part of the name "pos?". pos? is a function, which returns true if a number is positive, false otherwise. Function names ending in "?" by convention indicate that they return a boolean value (true or false). They are called "predicates". Sincerely Meikel PS: In f

Re: What role does ? operator play?

2011-05-19 Thread octopusgrabbus
Many Thanks. I'm interested in learning Clojure and not everything is obvious in books. On May 19, 9:20 am, Meikel Brandmeyer wrote: > Hi, > > ? is not an operator, but part of the name "pos?". pos? is a function, which > returns true if a number is positive, false otherwise. > > Function names e

Clojure example code snippets

2011-05-19 Thread dokondr
Hi! I am thinking about using Clojure for distributed NLP. Being an absolute newbie in Clojure I look for nice expressive code snippets. For example, I need an easy way to read text files such as in the following Python code: >>> for line in open("file.txt"): ... for word in line.split(): ... if w

Aw: Clojure example code snippets

2011-05-19 Thread Meikel Brandmeyer
Hi, something like the following should work. (with-open [rdr (java.io.FileReader. "file.txt")] (doseq [line (line-seq rdr) word (.split line "\\s")] (when (.endsWith word "ing") (println word Sincerely Meikel -- You received this message because you are subscribed to

Re: Clojure example code snippets

2011-05-19 Thread Jonathan Fischer Friberg
There is clojure.contrib.duck-streams/read-lines http://clojuredocs.org/clojure_contrib/clojure.contrib.duck-streams/read-lines Then it's a matter of (filter (partial re-matches #".*ing") (read-lines "/path/to/file")) Jonathan On Thu, May 19, 2011 at 4:52 PM, Meikel Brandmeyer wrote: > Hi, >

Re: clojure.contrib.sql => clojure.java.jdbc - looking for feedback!

2011-05-19 Thread Jim
On Apr 23, 9:38 am, Shantanu Kumar wrote: > > 5. Provide a mode to prevent write operations > > > Interesting idea but isn't that better handled by grants on the user > > accessing the database? > > The intention here is to proactively prevent errors from a development > standpoint. And then, so

Re: San Francisco Clojure Users

2011-05-19 Thread David Jagoe
On 18 May 2011 18:54, Emeka wrote: > David, > How is Clojure doing in Africa? There really aren't that many people using it among the people that I have spoken to. I've worked in the UK, Europe and the US and in comparison South Africa is a little bit behind and quite conservative when it comes t

Re: Clojure example code snippets

2011-05-19 Thread Benny Tsai
I think there can be multiple words on each line, so they have to be split into words first. Maybe something like: (ns example (:use [clojure.contrib.duck-streams :only (read-lines)])) (let [lines (read-lines "file.txt") words (mapcat #(.split % "\\s") lines) ing-words (filter (pa

Re: Aw: Clojure example code snippets

2011-05-19 Thread Benny Tsai
I think line-seq needs a java.io.BufferedReader instead of a java.io.FileReader. clojure.java.io has a reader function that constructs a java.io.BufferedReader from a filename, so this worked for me: (ns example (:use [clojure.java.io :only (reader)])) (with-open [rdr (reader "file.txt")]

Re: Aw: Clojure example code snippets

2011-05-19 Thread Benny Tsai
Oops. Just noticed that the original was not quoted in either of my previous emails, which makes things really confusing. My first reply (the one using read-lines) was an extension of odyssomay/Jonathan's code, and the second (with reader) was an extension of Meikel's code. Sorry guys. -- Y

Re: A simulation of the Monty Hall Problem

2011-05-19 Thread siyu798
Hi, I started learning clojure for a few months and this is what I have for the problem, and I find it running very slow if exceeding 100k trials, maybe it's because of using set? Any feedbacks will be appreciated. thx (require '[clojure.set :as set]) (def doors #{:a :b :c}) (defn rand-nth-set

Re: Radically simplified Emacs and SLIME setup

2011-05-19 Thread Paul Mooser
I had a similar issue with an existing project - it went away when I created a new project and did "lein deps". On May 18, 11:39 pm, Tassilo Horn wrote: > Exception in thread "main" java.lang.IllegalArgumentException: No value > supplied for key: 55298 > > I have to say that this project uses a

Re: Clojure example code snippets

2011-05-19 Thread dokondr
On May 19, 6:52 pm, Meikel Brandmeyer wrote: > Hi, > > something like the following should work. > > (with-open [rdr (java.io.FileReader. "file.txt")] >   (doseq [line (line-seq rdr) >           word (.split line "\\s")] >     (when (.endsWith word "ing") >       (println word > > Sincerely >

Re: Clojure example code snippets

2011-05-19 Thread Armando Blancas
Just in case I'll mention that Meikel's use of (with-open) will automatically close the reader. On May 19, 11:40 am, dokondr wrote: > On May 19, 6:52 pm, Meikel Brandmeyer wrote: > > > Hi, > > > something like the following should work. > > > (with-open [rdr (java.io.FileReader. "file.txt")] > >

Re: A simulation of the Monty Hall Problem

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 12:52 PM, siyu798 wrote: > Hi, I started learning clojure for a few months and this is what I have for > the problem, and I find it running very slow if exceeding 100k trials, maybe > it's because of using set?  Any feedbacks will be appreciated. thx > (require '[clojure.se

Re: Clojure stack

2011-05-19 Thread Phil Hagelberg
On May 18, 5:06 pm, Sean Corfield wrote: > I've seen a number of people struggle with the instructions here: > > http://clojure.org/getting_started > > Let's walk thru the process from a complete n00b's p.o.v. (since this > is the Getting Started page)... > > First thing discussed, the github repo

Race condition in update-proxy?

2011-05-19 Thread Ken Wesson
Update-proxy is not thread-safe. I took a look at the guts of it and: (. cv (visitField (+ (. Opcodes ACC_PRIVATE) (. Opcodes ACC_VOLATILE)) fmap (. imap-type (getDescriptor)) nil nil)) i.e. there's a private volatile mutable field rather than atom holding the function m

Re: Help: how to construct lazy sequences

2011-05-19 Thread timc
That was very helpful - thanks Meikel and Jonathon. -- 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 your first post.

Re: Clojure stack

2011-05-19 Thread pmbauer
The official way to get started has way too many sharp edges (Download JDK, install, set JAVA_HOME, add JAVA_HOME/bin to path, download clojure.zip, extract, sacrifice chicken, run java -cp clojure.jar clojure.main) ... at which point you get a kinda crappy REPL. Oops. Compare to (on linux): sud

Re: Clojure stack

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 5:35 PM, pmbauer wrote: > The official way to get started has way too many sharp edges > (Download JDK, install, set JAVA_HOME, add JAVA_HOME/bin to path, download > clojure.zip, extract, sacrifice chicken, run java -cp clojure.jar > clojure.main) ... at which point you get

Re: Clojure example code snippets

2011-05-19 Thread Andreas Kostler
Hi Armando, I'm working on a Clojurej library for sentiment analysis which doesn't contain everything you'd want for nlp but quite a nice subset of input modules (plain text corpora, rss feeds, html, etc...), tokenising/normalising filters (noise removal, porter stemmer, etc), distance/similarit

Re: Comparison of CCW and Enclojure

2011-05-19 Thread Ken Wesson
Found a new bug and it's a head-scratcher. Autocomplete quit working sometime overnight. Now I get a SocketException message "Software caused connection abort" if I hit control-space at the REPL. REPL process is connected OK -- I can evaluate forms at it -- so it's not the REPL-to-Eclipse socket co

Re: Clojure stack

2011-05-19 Thread pmbauer
> > The recommended way definitely should be one of the painless installs. > This works: > > * Download NetBeans, configuring on the NB homepage for J2SE, and run > installer > So does this: > > * Download Eclipse J2SE > Sure, but that's still a lot of work just to get a simple repl. Th

Re: Clojure example code snippets

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 5:47 PM, Andreas Kostler wrote: > Hi Armando, > I'm working on a Clojurej library for sentiment analysis which doesn't > contain everything you'd want for nlp but quite a nice subset of input > modules (plain text corpora, rss feeds, html, etc...), > tokenising/normalisin

Re: Clojure stack

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 5:50 PM, pmbauer wrote: >> The recommended way definitely should be one of the painless installs. >> This works: >> >> * Download NetBeans, configuring on the NB homepage for J2SE, and run >> installer >> >> So does this: >> >> * Download Eclipse J2SE > > Sure, but

Re: Comparison of CCW and Enclojure

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 5:48 PM, Ken Wesson wrote: > Found a new bug and it's a head-scratcher. And right on its heels, another one. CCW's REPL seems to have the desirable property that ctrl-dn at the most recent history item gets you a blank prompt. Or rather, it did. Now it gives me *clojure-ve

Re: Clojure stack

2011-05-19 Thread pmbauer
> > If ALL you want is a SIMPLE repl you can just go to the tryclojure site. :) > Not quite. As far as official disto's go, the current state is a little raw for getting started And having the official getting started instructions be (as you suggested) "So now you go download this 100MB IDE" is

Re: Clojure stack

2011-05-19 Thread László Török
Scala gets parallel collections (i.e. leverage multi-core CPUs) http://www.infoq.com/news/2011/05/scala-29;jsessionid=BCF6B009442F5F0D9C18A06D3790C3DA just to give this thread a new spark...:) 2011/5/19 Ken Wesson > On Thu, May 19, 2011 at 5:50 PM, pmbauer > wrote: > >> The recommended way de

Re: Clojure stack

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 5:58 PM, pmbauer wrote: >> If ALL you want is a SIMPLE repl you can just go to the tryclojure site. >> :) > > Not quite. > As far as official disto's go, the current state is a little raw for getting > started > And having the official getting started instructions be (as yo

Re: Clojure stack

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 6:02 PM, Ken Wesson wrote: > On Thu, May 19, 2011 at 5:58 PM, pmbauer wrote: >> "So now you go download this 100MB IDE" is a little heavy. No? > Don't forget the JDK alone weighs in at three-quarters of that: > > jdk-6u25-ea-bin-b03-windows-i586-27_feb_2011.exe, 76.69 MB

Re: A simulation of the Monty Hall Problem

2011-05-19 Thread siyu798
On Thursday, May 19, 2011 4:38:17 PM UTC-4, Ken Wesson wrote: > > On Thu, May 19, 2011 at 12:52 PM, siyu798 wrote: > > Hi, I started learning clojure for a few months and this is what I have > for > > the problem, and I find it running very slow if exceeding 100k trials, > maybe > > it's becau

Re: Clojure stack

2011-05-19 Thread pmbauer
Mmm, not quite. Doesn't clojure run just fine with the 15MB JVM? -- 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 your

Re: A simulation of the Monty Hall Problem

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 6:16 PM, siyu798 wrote: > On Thursday, May 19, 2011 4:38:17 PM UTC-4, Ken Wesson wrote: >> On Thu, May 19, 2011 at 12:52 PM, siyu798 wrote: >> >                        (set/difference doors opened-door picked-door) >> >> Shouldn't that be wrapped in (first ...) or somethin

Re: Clojure stack

2011-05-19 Thread David Nolen
On Thu, May 19, 2011 at 6:00 PM, László Török wrote: > Scala gets parallel collections (i.e. leverage multi-core CPUs) > > > http://www.infoq.com/news/2011/05/scala-29;jsessionid=BCF6B009442F5F0D9C18A06D3790C3DA > > just to give this thread a new spark...:) > Clojure used to have parallel collec

Re: Clojure stack

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 6:36 PM, David Nolen wrote: > On Thu, May 19, 2011 at 6:00 PM, László Török wrote: >> >> Scala gets parallel collections (i.e. leverage multi-core CPUs) >> >> >> http://www.infoq.com/news/2011/05/scala-29;jsessionid=BCF6B009442F5F0D9C18A06D3790C3DA >> >> just to give this

Re: Clojure stack

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 6:17 PM, pmbauer wrote: > Mmm, not quite. > Doesn't clojure run just fine with the 15MB JVM? Do you mean the JRE? And if so: for development, rather than just deployment? -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the

Re: A simulation of the Monty Hall Problem

2011-05-19 Thread siyu798
On Thursday, May 19, 2011 6:36:34 PM UTC-4, Ken Wesson wrote: > > On Thu, May 19, 2011 at 6:16 PM, siyu798 wrote: > > On Thursday, May 19, 2011 4:38:17 PM UTC-4, Ken Wesson wrote: > >> On Thu, May 19, 2011 at 12:52 PM, siyu798 wrote: > >> >(set/difference doors opened-do

Re: Clojure stack

2011-05-19 Thread pmbauer
I'm beginning to think this has degenerated a bit into argument for arguments sake. Yes, JRE. You don't need the JDK to read/eval .clj files. And in the context of where this all started, namely, critiques to the current getting started experience for new users, a 75MB JDK + 100MB IDE is exact

Re: Radically simplified Emacs and SLIME setup

2011-05-19 Thread Phil Hagelberg
On May 18, 11:39 pm, Tassilo Horn wrote: > I tried it by first deinstalling any clojure/swank/SLIME packages I > had.  Then I installed clojure-mode 1.9.0 from the marmalade-repo. > > In a terminal, I did > >   $ lein upgrade        # ==> 0.6.3 >   $ lein plugin install swank-clojure 1.4.0-SNAPSHO

Re: Clojure stack

2011-05-19 Thread Korny Sietsma
Just adding my +1 - as someone relatively new to clojure, leiningen is a great way to get up and running, for a reasonably experienced developer. (It's a big improvement on when I first tried clojure a couple of years ago!) There seem to be windows instructions at https://github.com/technomancy/le

Re: Clojure stack

2011-05-19 Thread mike.w.me...@gmail.com
pmbauer wrote: >I'm beginning to think this has degenerated a bit into argument for >arguments sake. > >Yes, JRE. You don't need the JDK to read/eval .clj files. And in the >context of where this all started, namely, critiques to the current >getting >started experience for new users, a 75MB J

Re: Clojure stack

2011-05-19 Thread Sean Corfield
On Thu, May 19, 2011 at 12:16 AM, Thorsten Wilms wrote: > After initially installing a Clojure package on Ubuntu, I then learned that > it was totally unnecessary for a project using Leiningen ... Yeah, part of me wishes that Leiningen would get official endorsement as "the" build tool for Clojur

Re: Clojure stack

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 7:13 PM, pmbauer wrote: > Lein is one such option, but unlikely to get official recognition giving > clojure/core's (arguably correct) decision to stick to maven. Talk about a heavyweight, intimidating experience. :) -- Protege: What is this seething mass of parentheses?

Re: Clojure stack

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 7:43 PM, mike.w.me...@gmail.com wrote: > The "download the massive IDE" path seems to presume that a newcomer > actually needs something more than "a simple REPL" in order to get started. > I'd claim that's wrong - at least in a world where any computer you'd run > clojure

Re: A simulation of the Monty Hall Problem

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 6:43 PM, siyu798 wrote: >> There's a difference between :a and #{:a}, though, and it will cause >> the switch case to never win since if prize-door is :a and picked-door >> ends up #{:a} they won't compare equal. > > prize-door is a set Eh. Your implementation is a bit ...

Re: extending types

2011-05-19 Thread Lachlan
Hi Ken, I hadn't thought of using explicit metadata for this purpose, I guess I was thinking that the class of the object would determine what it could do. Just working through this, if we take your example above, what if I wanted to override the 'put' method rather than define a new one, since w

Google Refine

2011-05-19 Thread Daniel Gagnon
Google just launched and interesting power tool to clean up messy data which you might want to look at: http://code.google.com/p/google-refine/wiki/Screencasts Sounds pretty nifty isn't it? What they do not mention in the screencast (or anywhere else for that matter), is that it comes with cloju

Re: Clojure stack

2011-05-19 Thread michele
It's not really the Emacs tools that are a problem, but the huge amount of web pages trying - with good intentions - to help you installing the Emacs-Clojure stack, but usually lacking some important detail. It feels like playing a jig-saw puzzle without being able to look at the picture on the box

Re: Google Refine

2011-05-19 Thread dysinger
It's a way older older version of clojure but it's in there. I've played around with it. -- 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 - p

Re: Radically simplified Emacs and SLIME setup

2011-05-19 Thread Tassilo Horn
Phil Hagelberg writes: Hi Phil, >>   $ lein upgrade        # ==> 0.6.3 >>   $ lein plugin install swank-clojure 1.4.0-SNAPSHOT > > There is no Leiningen version 0.6.3--I'm assuming you're running > 1.5.2? Ups, you are correct. ;-) >> Reflection warning, swank/util/io.clj:15 - call to java.lang

Re: extending types

2011-05-19 Thread Ken Wesson
On Thu, May 19, 2011 at 11:26 PM, Lachlan wrote: > Just working through this, if we take your example above, what if I > wanted to override the 'put' method rather than define a new one, > since we don't have access to 'proxy-super'.  For example making a map > that enforces storage of dates in a

Re: extending types

2011-05-19 Thread Ken Wesson
On Fri, May 20, 2011 at 2:54 AM, Ken Wesson wrote: > => (def r (put (DateMap. {}) :foo (java.util.Date.))) > #'user/r > => r > {:foo "Thu May 19 22:44:37 PDT 2011"} > => (get-as-date r :foo) > # Bah, copy and paste error. Test it and you'll find it works regardless. Somehow I got the result from