Re: My first use of cells: hashing

2010-02-28 Thread Meikel Brandmeyer
Hi, On Sat, Feb 27, 2010 at 06:52:28PM -0500, David Nolen wrote: > > ? http://richhickey.github.com/clojure-contrib/dataflow-api.html > > > There is no official Cells code. There is a only a gist of some work in > progress. I think this is a misunderstanding. There is a "Cells" implementation in

Re: functional abstraction

2010-02-28 Thread Jeff Rose
If anything, the defprotocol and deftype stuff that's on the way is more along the lines of an abstract class because you can define a protocol, acting a sort of modularized interface, and then you can compose types by grouping together functions that implement one ore more protocols. Anyway, I do

Implementing a class in clojure, calling it from java

2010-02-28 Thread Dan Becker
Hi, I'm trying to write a java class in clojure, and then call it from java. But I keep getting IllegalArgumentExceptions. file hello.clj: (ns hello (:gen-class :methods [ [fooMeth [] String]]) ) (defn -fooMeth [] "fooMeth") file TestIt2.java: public class TestIt2 { public st

Problemm with JComponent

2010-02-28 Thread Sergio Arbeo
Hi, all: I'm learning Clojure through porting Magick4J to clojure, I call it rinzelight. I'm having problems to port the display method ( http://github.com/Serabe/RMagick4J/blob/master/Magick4J/src/magick4j/MagickImage.java#L271 ). http://github.com/Serabe/rinzelight/blob/master/src/rinzelight/di

Re: prn to a file with large data structures?

2010-02-28 Thread NovusTiro
Ahhh thanks that did the trick! On Feb 25, 9:57 am, Adrian Cuthbertson wrote: > Try including [*print-dup* true] in the binding; > > (defn write-nick-sets [file-name obj]] >   (with-open [w (FileWriter. (File. file-name))] >     (binding [*out* w *print-dup* true] (prn obj > > You can read it

Question about how to write efficient code in functional style

2010-02-28 Thread logan
Let's say I want to write a function that takes as an argument a list of n numbers, and returns 4 lists, a list of odd numbers that are multiples of 5, a list of even numbers that are multiples of 5, a list of odd numbers that are not multiples of 5, and a list of even numbers that are not multiple

Re: Question about how to write efficient code in functional style

2010-02-28 Thread e
Someone will have an elegant solution, but what comes to my mind is a (somewhat) brute force "loop-recur" ... not not that much different from what you suggested. It would pass the "under construction" return lists to itself and a dwindling amount ("rest") of the original list. Add "first" from t

Re: Question about how to write efficient code in functional style

2010-02-28 Thread Heinz N. Gies
How about reducing it? Something along the limes of: (not tested) (reduce (fn [lists number] (update-in lists [ (if (odd? number) (if (= 0 (mod number 5) :odd-5 :odd) (if (= 0 (mod number 5) :even-5 :even)] (fn [l] (conj l number)) numbers) Regards, Heinz

Re: Implementing a class in clojure, calling it from java

2010-02-28 Thread Adrian Cuthbertson
Hi Dan, you need to include an arg for "this" in -fooMeth, i.e (defn -fooMeth [this] "fooMeth") or (defn -fooMeth [_] "fooMeth") - Rgds, Adrian On Sun, Feb 28, 2010 at 12:06 AM, Dan Becker wrote: > Hi, > > I'm trying to write a java class in clojure, and then call it from > java. But I keep get

Re: Question about how to write efficient code in functional style

2010-02-28 Thread Jarkko Oranen
On Feb 28, 4:03 pm, "Heinz N. Gies" wrote: > How about reducing it? > > Something along the limes of: (not tested) > > (reduce (fn [lists number] >         (update-in lists [ >           (if (odd? number) >           (if (= 0 (mod number 5) :odd-5 :odd) >           (if (= 0 (mod number 5) :even-

Re: bug: clojure.contrib.json should not default to use keywords.

2010-02-28 Thread Stuart Sierra
Mark, Thank you! I argued for this for months, but everyone kept insisting on keywords by default. Now you just have to convince the other 2 people who actually use clojure.contrib.json. -SS On Feb 27, 3:55 pm, MarkSwanson wrote: > Hello, > > Consider the following valid JSON: > > Clojure=>

Re: bug: clojure.contrib.json should not default to use keywords.

2010-02-28 Thread Heinz N. Gies
I use c.c.json heavily in my project and I kind of agree, it should be strings since in the json definition keys have to be strings, only problem is serialization as in how to serialize a keyword them? Regards, Heinz On Feb 28, 2010, at 15:36 , Stuart Sierra wrote: > Mark, > > Thank you! I

Re: Question about how to write efficient code in functional style

2010-02-28 Thread Meikel Brandmeyer
Hi, On Sun, Feb 28, 2010 at 06:29:13AM -0800, Jarkko Oranen wrote: > 3) The reduce needs an empty map as an init value. Otherwise you get > an exception (You might even want to populate it with empty vectors, > but it's not necessary since conjing to nil produces a list) Quiz time: What is the d

Re: Question about how to write efficient code in functional style

2010-02-28 Thread carlitos
On Feb 28, 2:54 am, logan wrote: > Let's say I want to write a function that takes as an argument a list > of n numbers, and returns 4 lists, a list of odd numbers that are > multiples of 5, a list of even numbers that are multiples of 5, a list > of odd numbers that are not multiples of 5, and a

Re: bug: clojure.contrib.json should not default to use keywords.

2010-02-28 Thread joshua-choi
As a small note, according to http://clojure.org/reader, Clojure keywords and symbols are allowed to contain only alphanumeric characters, *, +, !, -, _, and ?. Spaces aren’t allowed, but the keyword function allows them anyway because it doesn’t do any checking for validity for performance. I’m to

Re: Implementing a class in clojure, calling it from java

2010-02-28 Thread Dan Becker
Ah, thank you! I guess that makes sense. But it doesn't seem to be documented directly anywhere, though the examples at http://clojure.org/compilation do show the need to do this. Dan On Feb 28, 7:10 am, Adrian Cuthbertson wrote: > Hi Dan, you need to include an arg for "this" in -fooMeth, i.e

Re: functional abstraction

2010-02-28 Thread reynard
Perhaps my choice of function names (abstract and concrete) for my original post is not very appropriate. I did not mean to apply the OO concept of abstract class, abstract methods, etc. Since it seemed that my original post did not convey my query clearly, I would try to depict it with some "co

difference between if/when

2010-02-28 Thread Аркадий Рост
Hi! hmm...I don't understand why clojure when and if simultaneously? What is the diffirences between them and when I should use one instead another one? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goog

Re: difference between if/when

2010-02-28 Thread reynard
user> (when true (println "line 1") (println "line 2") (println "line 3") (println "there is no need to use #'do") (println "there is nothing to evaluate when false and return nil")) line 1 line 2 line 3 there is no need to use #'do there is nothing to evalua

Re: functional abstraction

2010-02-28 Thread reynard
Perhaps my choice of function names (abstract and concrete) for my original post is not very appropriate. I did not mean to apply the OO concept of abstract class, abstract methods, etc. Since it seems that my original post did not convey my query clearly, I would try to depict it with some "conc

Re: Question about how to write efficient code in functional style

2010-02-28 Thread jim
Here's a similar idea (also untested) (defn which-list [number] (let [by-5 (zero? (mod number 5))] (cond (and (odd? number) by-5) [:odd-5] by-5 [:even-5] (

Re: difference between if/when

2010-02-28 Thread DanL
Hello! On 28 Feb., 18:08, Аркадий Рост wrote: > Hi! > > hmm...I don't understand why clojure when and if simultaneously? What > is the diffirences between them and when I should use one instead > another one? Besides the implicit do, which reynard mentioned, it's generally idiomatic to use while

Re: functional abstraction

2010-02-28 Thread Jarkko Oranen
On Feb 28, 7:36 pm, reynard wrote: > Perhaps my choice of function names (abstract and concrete) for my > original post is not very appropriate.  I did not mean to apply the OO > concept of abstract class, abstract methods, etc.  Since it seems that > my original post did not convey my query cle

Re: difference between if/when

2010-02-28 Thread Richard Newman
hmm...I don't understand why clojure when and if simultaneously? What is the diffirences between them and when I should use one instead another one? Disregarding all of the practical benefits (such as an implicit do): languages often incorporate apparently redundant constructs because one of

Re: Implementing a class in clojure, calling it from java

2010-02-28 Thread Michał Marczyk
On 28 February 2010 16:24, Dan Becker wrote: > Ah, thank you! I guess that makes sense. But it doesn't seem to be > documented directly anywhere, though the examples at > http://clojure.org/compilation > do show the need to do this. Try Meikel Brandmeyer's post "gen-class – how it works and how

Re: difference between if/when

2010-02-28 Thread Steven E. Harris
Richard Newman writes: > There are more subtle clues that you'll pick up in certain people's > styles, too -- I'm sure my use of when has a very different pattern to > a Java guy's, colored by my Common Lisp experience. I'm still undecided whether to shake this habit: , | (defmacro unless [

Re: difference between if/when

2010-02-28 Thread Richard Newman
I'm still undecided whether to shake this habit: , | (defmacro unless [pred & body] | `(when-not ~pred ~...@body)) ` Heh. I still think that "unless" is a better name than "when-not", but I've migrated pretty easily. This is an interesting point, though -- does "unless" communicat

Re: difference between if/when

2010-02-28 Thread Michał Marczyk
I always thought unless is a very nice name for if-not... I'm beginning to understand why we have if-not / when-not and no unless out of the box. :-) All best, Michał -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

Re: difference between if/when

2010-02-28 Thread Mike Meyer
On Sun, 28 Feb 2010 14:18:50 -0800 Richard Newman wrote: > This is an interesting point, though -- does "unless" communicate > something slightly different to* "when not", despite being > functionally identical? And is the distinction important enough to > justify a move towards a confusing

Re: difference between if/when

2010-02-28 Thread Steven E. Harris
Richard Newman writes: > Incidentally, I initially didn't know about `when-not` -- I figured > that `unless` had simply been omitted -- so I defined: > > (defmacro unless [pred & body] > `(when (not ~pred) ~...@body)) I did the same, and then was frustrated enough to dig through the core API d

Re: bug: clojure.contrib.json should not default to use keywords.

2010-02-28 Thread MarkSwanson
On Feb 28, 10:34 am, joshua-choi wrote: > As a small note, according tohttp://clojure.org/reader, Clojure > keywords and symbols are allowed to contain only alphanumeric > characters, *, +, !, -, _, and ?. Spaces aren’t allowed, but the > keyword function allows them anyway because it doesn’t do

Re: bug: clojure.contrib.json should not default to use keywords.

2010-02-28 Thread Richard Newman
For an example outside of JSON: recently Compojure changed how it works so the HTTP request properties are all converted to keywords by default. I can see the appeal, but now anyone using Compojure has the increased incidental complexity of possible keyword violations. Imagine if you were integrat

Re: newbie question: Please help me stop creating constructors

2010-02-28 Thread Yaron
Richard, I spent quite a bit of time thinking about what you said. So I rewrote the whole kit and kaboodle. My understanding of your mail led me to take the approach of defining functions who take as arguments the invariant values and who output functions that take variant values. For example: (d

Re: difference between if/when

2010-02-28 Thread Аркадий Рост
ok. Thanks. -- 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. To unsubscribe from this group, send em

newbie code (genetic programming) and questions (dev environments)

2010-02-28 Thread Lee Spector
I've just recently begun to work with Clojure and I am finding it quite gratifying. I am a long-time Lisper (several dialects) but my Java experience is limited and largely in the sheltered environment of Processing (processing.org). Anyway, my first Clojure exercise has been a version of my P

Clojure syntax highlight for web sites

2010-02-28 Thread Ivan
Hello All, Do you happen to know of any JavaScript syntax highlighting library, alike http://code.google.com/p/syntaxhighlighter/ or http://code.google.com/p/google-code-prettify/, supporting Clojure and not just Lisp. I've been trying to find one to no avail. Cheers, Ivan. -- You received this

Re: newbie code (genetic programming) and questions (dev environments)

2010-02-28 Thread cej38
> > - When I run clj (from the most recent ClojureX) on the command line with -i > and a source file it runs the file but then hangs. If I also specify -r then > I get a REPL after the file runs, which is nice, but I was hoping that > without -r it would terminate and return to a shell prompt w

Re: newbie code (genetic programming) and questions (dev environments)

2010-02-28 Thread David Nolen
On Sun, Feb 28, 2010 at 2:38 PM, Lee Spector wrote: > On the development environment front: Is anyone contemplating creating a > Mac OS X "Clojure in a Box"? I would be an enthusiastic user. If it could > have roughly the feature set of the old Macintosh Common Lisp IDE then I > would be ecstatic

Does/will clojure run on ARM based smartbook?

2010-02-28 Thread reynard
Anyone has first hand experience? Thanks. -- 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. To unsub

Re: newbie code (genetic programming) and questions (dev environments)

2010-02-28 Thread Konrad Hinsen
On 28 Feb 2010, at 20:38, Lee Spector wrote: that just published a special issue on parallel evolutionary algorithms, so I know of a lot of options there! -- but for now I just want the basic generational algorithm to be expressed as naturally as possible in Clojure. There seem to be many o

Re: newbie question: Please help me stop creating constructors

2010-02-28 Thread Richard Newman
So I rewrote the whole kit and kaboodle. My understanding of your mail led me to take the approach of defining functions who take as arguments the invariant values and who output functions that take variant values. For example: I'm not sure how much functional programming experience you have, bu