Re: What am I not getting here?

2011-01-07 Thread new2clojure
Thank you all for your help, I appreciate it very much. I come from the world of OO programming and I am bending my head backwards to try to think in the functional paradigm. Bellow you will find my version of Peter Norvig's spell checker (http://norvig.com/spell-correct.html) in clojure,

Re: What am I not getting here?

2011-01-07 Thread Baishampayan Ghose
Bellow you will find my version of Peter Norvig's spell checker (http://norvig.com/spell-correct.html) in clojure, followed by the java version. I coded the later first and then I attempted to translate it. In a few months time I will try to implement it again from scratch (in clojure) and I

What am I not getting here?

2011-01-06 Thread new2clojure
Hi, I am trying to store into a map the frequency of each [a-z]+ word in a file. When I run this code in the repl the resulting dictionary is empty. How should I adapt my code to get this functionality right?. Thank you in advance (import (java.io BufferedReader FileReader)) (def dictionary

Re: What am I not getting here?

2011-01-06 Thread Jason Wolfe
You're not capturing the output of the reduce anywhere; doseq is for side-effects only. If you wrapped the doseq in a (def dictionary ...) it would work, but this is not recommended. Instead, you should either use nested reductions, or produce a simple list of tokens first (simpler): (defn

Re: What am I not getting here?

2011-01-06 Thread Benny Tsai
I was typing up an answer, but Jason answered faster and better :) The only thing I have to add is that 'frequencies' is also in clojure core as of 1.2. On Jan 6, 1:13 pm, Jason Wolfe ja...@w01fe.com wrote: You're not capturing the output of the reduce anywhere; doseq is for side-effects only.

Re: What am I not getting here?

2011-01-06 Thread Ken Wesson
On Thu, Jan 6, 2011 at 1:49 PM, new2clojure miguel.arre...@gmail.com wrote: Hi, I am trying to store into a map the frequency of each [a-z]+ word in a file. When I run this code in the repl the resulting dictionary is empty. How should I adapt my code to get this functionality right?.

Re: What am I not getting here?

2011-01-06 Thread Sean Corfield
On Thu, Jan 6, 2011 at 10:49 AM, new2clojure miguel.arre...@gmail.com wrote: I am trying to store into a map the frequency of each [a-z]+ word in a file. When I run this code in the repl the resulting dictionary is empty. How should I adapt my code to get this functionality right?. Other