Re: Java interop question: proxy or gen-class?

2010-04-13 Thread Gregg Williams
Since my last post, I've implemented and successfully run everything in this sample program except the ToggleShape class, and I absolutely cannot figure out how to use proxy correctly. Here's the Java code that I'm trying to re-create in Clojure: class ToggleShape extends PPath { priva

Re: numbers at the end of generated class name using compile

2010-04-13 Thread Travis
On Apr 13, 5:14 pm, Alex Osborne wrote: > Travis writes: > > I'm just curious where those numbers come from. For example, if I > > compile the class bar.clj containing: > > > (ns bar) > > (defn foo [] > >   nil) > > > I'll get three classes, one of which is: > > > bar$foo__5.class > > The number

Re: numbers at the end of generated class name using compile

2010-04-13 Thread Alex Osborne
Travis writes: > I'm just curious where those numbers come from. For example, if I > compile the class bar.clj containing: > > (ns bar) > (defn foo [] > nil) > > I'll get three classes, one of which is: > > bar$foo__5.class The numbers are just a global incrementing counter (the same one used

Re: matching symbols in a dictionary

2010-04-13 Thread Josh Stratton
> You do mean keywords rather than symbols, right? A symbol would be > 'hello. A keyword is :hello. > The ruby name for the clojure keyword concept is "symbol". I used to > get the terminology backwards because of that. > > (assert (= (name :hello) "hello")) > (assert (= :hello (keyword "hello")))

Re: matching symbols in a dictionary

2010-04-13 Thread Travis
You do mean keywords rather than symbols, right? A symbol would be 'hello. A keyword is :hello. The ruby name for the clojure keyword concept is "symbol". I used to get the terminology backwards because of that. (assert (= (name :hello) "hello")) (assert (= :hello (keyword "hello"))) On Apr 13, 2

matching symbols in a dictionary

2010-04-13 Thread strattonbrazil
I want to map a dictionary and do different things depending on the key. I was planning on using an if-clause, but I'm not sure how to compare symbols to strings. Something like (map (fn [k v] (if (== k "hello") ... ...) {:hello 1 :goodbye 2}) How would I normally compare symbols and strings?

numbers at the end of generated class name using compile

2010-04-13 Thread Travis
I'm just curious where those numbers come from. For example, if I compile the class bar.clj containing: (ns bar) (defn foo [] nil) I'll get three classes, one of which is: bar$foo__5.class What is that "5" for? Thanks, Travis -- You received this message because you are subscribed to the G

Re: Testing to see if an object is an element of a sequence

2010-04-13 Thread Chris Jenkins
Thanks guys :-). I didn't know about some and includes?. On 4/13/10, Stuart Halloway wrote: > Hi Chris, > > includes? is in clojure.contrib.seq. Note that it runs in linear time. > > This will feature prominently in the FAQ when I update it. :-) > > Stu > >> Hi, >> >> Is there a standard function

Simple macro hack for converting to fast primitive math

2010-04-13 Thread David Nolen
Recently I've been working on bits of code that require me to type in fairly long sequences of math operations. I found it tedious to convert these to type hinted binary operations so I've created the following truly simplistic macro: http://gist.github.com/364328 It lets you write things like th

Re: Understanding lazy-seq

2010-04-13 Thread Edmund Jackson
Wow - thanks everybody. On 13 Apr 2010, at 14:32, Rich Hickey wrote: > > > On Apr 12, 7:53 pm, Stuart Halloway wrote: >> Hi Edmund, >> >> This is a regression since last Tuesday's commit >> f81e612cc9ff91ddefc1d86e270cd7f018701802. Thanks for catching it! >> >> Stu >> >> >> >>> Dear Clo

Re: CSV Lib

2010-04-13 Thread liebke
OpenCSV is included with Incanter and used in the incanter.io/read- dataset function. On Apr 13, 10:30 am, Sean Devlin wrote: > I'll be greedy... is there a known Clojure wrapper? > > On Apr 13, 10:27 am, Meikel Brandmeyer wrote: > > > > > Hi, > > > On Apr 13, 4:25 pm, Sean Devlin wrote: > >

Re: CSV Lib

2010-04-13 Thread Sean Devlin
Challenge Accepted. Will work on this when Rich says 1.2 is ready for beta (i.e. API freeze). Sean On Apr 13, 10:33 am, Stuart Halloway wrote: > Here's a pure Clojure one:http://github.com/davidsantiago/clojure-csv > > And here's a challenge for you: Use protocols to describe a minimal   > cont

Re: CSV Lib

2010-04-13 Thread Stuart Halloway
Here's a pure Clojure one: http://github.com/davidsantiago/clojure-csv And here's a challenge for you: Use protocols to describe a minimal contract for CSV parsing, then show how protocols solve the expression problem by letting you backfit to existing Java libs without wrappers or adapters

Re: CSV Lib

2010-04-13 Thread Sean Devlin
I'll be greedy... is there a known Clojure wrapper? On Apr 13, 10:27 am, Meikel Brandmeyer wrote: > Hi, > > On Apr 13, 4:25 pm, Sean Devlin wrote: > > > Anyone know where to start with parsing a csv file? > > I found OpenCSV to be useful. > > Sincerely > Meikel -- You received this message bec

Re: CSV Lib

2010-04-13 Thread Meikel Brandmeyer
Hi, On Apr 13, 4:25 pm, Sean Devlin wrote: > Anyone know where to start with parsing a csv file? I found OpenCSV to be useful. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegrou

CSV Lib

2010-04-13 Thread Sean Devlin
Anyone know where to start with parsing a csv file? -- 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: Testing to see if an object is an element of a sequence

2010-04-13 Thread Stuart Halloway
Hi Chris, includes? is in clojure.contrib.seq. Note that it runs in linear time. This will feature prominently in the FAQ when I update it. :-) Stu Hi, Is there a standard function to test to see if an object is an element of a sequence? I'm looking for an equivalent of Haskell's elem fu

Re: Testing to see if an object is an element of a sequence

2010-04-13 Thread Meikel Brandmeyer
Hi, On Apr 13, 4:20 pm, Chris Jenkins wrote: > Is there a standard function to test to see if an object is an element of a > sequence? I'm looking for an equivalent of Haskell's elem function. > > I wrote my own (badly)... > > (defn elem? [obj l] >   (if (empty? l) >     false >     (if (= obj (

Testing to see if an object is an element of a sequence

2010-04-13 Thread Chris Jenkins
Hi, Is there a standard function to test to see if an object is an element of a sequence? I'm looking for an equivalent of Haskell's elem function. I wrote my own (badly)... (defn elem? [obj l] (if (empty? l) false (if (= obj (first l)) true (elem? obj (rest l) ...but

Re: Clojure Concurrency Screencast Available

2010-04-13 Thread Craig Andera
Glad you've enjoyed them! 2010/4/13 Pelayo Ramón > I have seen the first 2, and as a clojure noobie I have to say that > they are great. Thanks a lot. > > On Tue, Apr 13, 2010 at 3:10 PM, Craig Andera > wrote: > > If you mean "downloading and viewing on my computers and mobile devices", > > the

Re: newbie hiccup with hiccup

2010-04-13 Thread James Reeves
On 13 April 2010 14:13, Nurullah Akkaya wrote: > 0.2.2 fixes this issue. Yes, and currently Hiccup 0.2.3 is the latest version. I'd recommend using 0.2.3, as it has no known bugs as of this post. - James -- You received this message because you are subscribed to the Google Groups "Clojure" gro

Re: Understanding lazy-seq

2010-04-13 Thread Rich Hickey
On Apr 12, 7:53 pm, Stuart Halloway wrote: > Hi Edmund, > > This is a regression since last Tuesday's commit   > f81e612cc9ff91ddefc1d86e270cd7f018701802. Thanks for catching it! > > Stu > > > > > Dear Clojurians, > > >    I have been trying to get a proper grip on the operation of lazy- > > seq

Re: Clojure Concurrency Screencast Available

2010-04-13 Thread Pelayo Ramón
I have seen the first 2, and as a clojure noobie I have to say that they are great. Thanks a lot. On Tue, Apr 13, 2010 at 3:10 PM, Craig Andera wrote: > If you mean "downloading and viewing on my computers and mobile devices", > then sure. There's no DRM. There's not even any registration require

Re: newbie hiccup with hiccup

2010-04-13 Thread Nurullah Akkaya
Which version of hiccup? there was a bug discussed in compojure mailing list couple of days ago, where hiccup pre compilation fails when there are vars inside maps. http://groups.google.com/group/compojure/browse_thread/thread/d512a04a08aaa64f# 0.2.2 fixes this issue. -- Nurullah Akkaya http://n

Re: Clojure Concurrency Screencast Available

2010-04-13 Thread Craig Andera
If you mean "downloading and viewing on my computers and mobile devices", then sure. There's no DRM. There's not even any registration required. But if by "copying" you mean "distributing to other people", then no. If you have some other scenario in mind, contact me off-list and I'll hook you up wi

Re: Clojure Concurrency Screencast Available

2010-04-13 Thread Hasan Hasan
Hi, Is downloading and copying the videos free? On Tue, Apr 13, 2010 at 1:10 AM, Craig Andera wrote: > That's typing-speed-mode. I wrote it. :) Available here [1]. You'll > probably also want this [2] in your .emacs. > > [1] > http://www.pluralsight-training.net/community/blogs/craig/archive/200

Re: removing parethesis

2010-04-13 Thread Jeffrey Cummings
try the following: (defn avg-coll [coll] (/ (reduce + coll) (count coll))) then use it on your collection of collections: (map #(avg-coll %) (list (list 1 2 3) (list 6 4 2))) this will give you (2 4) hope this helps. On Apr 12, 10:48 pm, Glen Rubin wrote: > I am working with a collection of

newbie hiccup with hiccup

2010-04-13 Thread Micah Martin
Hey All, Does anyone know why the first expression below works but the second doesn't? What's the right way to do this? user=> (use 'hiccup.core) nil user=> (html (for [image ["image017.jpg" "image021.jpg"]] [:img image])) "image017.jpgimage021.jpg" user=> (html (for [image ["image017.jpg" "ima

Re: Understanding lazy-seq

2010-04-13 Thread Sean Devlin
How would one write a unit test to catch this type of thing? On Apr 12, 7:53 pm, Stuart Halloway wrote: > Hi Edmund, > > This is a regression since last Tuesday's commit   > f81e612cc9ff91ddefc1d86e270cd7f018701802. Thanks for catching it! > > Stu > > > Dear Clojurians, > > >    I have been tryin

Re: removing parethesis

2010-04-13 Thread Mark J. Reed
On Tuesday, April 13, 2010, Mark J. Reed wrote: > (defn mean [& rest] (/ (apply + reset) (count rest))) that "reset" should be "rest". > And then use the same trick with it in place of +: > (apply map mean '((1 2 4) (2 4 6) (1 3 5))) > which yields (4/3 3 5). -- Mark J. Reed -- You receiv

Re: removing parethesis

2010-04-13 Thread Michael Kohl
On Tue, Apr 13, 2010 at 10:09 AM, Michael Kohl wrote: > Disclaimer: I have not had my morning coffee yet And I apparently missed a mail in this thread, (apply map +) was already posted an is a lot more straightforward. -- You received this message because you are subscribed to the Google Groups

Re: removing parethesis

2010-04-13 Thread Michael Kohl
On Tue, Apr 13, 2010 at 4:48 AM, Glen Rubin wrote: > I want to create an average sequence such that all of the first > elements are averaged, all of the second elements, etc Sounds like you want a traspose function. Here you go: (defn transpose [m] (apply map list m)) Example: user=> (de

Interesting Facebook blog post on Concurrency (mentions Clojure)

2010-04-13 Thread Baishampayan Ghose
Hi, This is an interesting article on the problems associated with concurrency and some of the current solutions. http://www.facebook.com/notes/facebook-engineering/a-dismal-guide-to-concurrency/379717628919 It mentions Clojure for a bit and says this about the general idea behind STMs - "