Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-25 Thread Aviad Reich
here is the final version of the implementation. http://gist.github.com/313558 again, any thought would be great. Aviad. On 22 February 2010 22:11, Aviad Reich avi@gmail.com wrote: I don't mean to signal the end of this thread, but I just wanted to thank you all for you replies. I will

order of function definition

2010-02-25 Thread reynard
I define a function foo in which it calls an auxiliary function bar, which is not yet defined, and a compiler exception is raised claiming unable to resolve symbol bar. Is there a way that I can define the functions in any order I want, without taking care of defining the auxiliary function

Re: order of function definition

2010-02-25 Thread Laurent PETIT
not yet. But you can just declare the function, before implementing it: (declare bar) (defn foo [] (bar hello)) (defn bar [man] (println hello man)) Be aware that if you need to typehint bar, you'll also need to type hint the bar declaration, so that the compilation of foo can use this

Re: order of function definition

2010-02-25 Thread Meikel Brandmeyer
Hi, On Feb 25, 11:24 am, reynard atsan...@gmail.com wrote: I define a function foo in which it calls an auxiliary function bar, which is not yet defined, and a compiler exception is raised claiming unable to resolve symbol bar. Is there a way that I can define the functions in any order I

Re: clojure-clr how to wire up a delegate

2010-02-25 Thread dmiller
Parallel to proxy, clojure-clr adds a gen-delegate. Example code is in http://github.com/richhickey/clojure-clr/blob/master/Clojure/Clojure.Source/clojure/samples/celsius.clj Specifically, for adding an EventHandler: (.add_Click button (gen-delegate EventHandler [sender args] (let [c

clojure.zip - throws exception

2010-02-25 Thread Amitava Shee
I am getting the following exception while trying to use clojure.zip user= (use '[clojure.zip :as zip]) java.lang.IllegalStateException: next already refers to: #'clojure.core/next in namespace: user (NO_SOURCE_FILE:0) What I am I missing? -- You received this message because you are

possible errors in ns documentation

2010-02-25 Thread j1n3l0
Hi all, I'm not sure if this is the right place to raise this. I am new to clojure and was going through the docs for namespaces here: http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/ns In the example there it implies that the way to import functions into your namespace

prn to a file with large data structures?

2010-02-25 Thread NovusTiro
I'm trying to prn a large data structure to a file so I can later read it back in, like so - (defn write-nick-sets [file-name obj] (binding [*out* (java.io.FileWriter. file-name)] (prn obj))) obj here is a map with a string as its key and another map as its value. The nested map has a

Re: order of function definition

2010-02-25 Thread Tom Danielsen
(declare bar) -- Freedom's just another word for nothing left to lose -- 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

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-25 Thread fra
Hi, I have a small improvement. The function / called with only argument returns the inverse, so you can define g-mean and h-mean more shortly: (defn g-mean [coll] (expt (reduce * coll) (/ (count coll (defn h-mean [coll] ;; Michael Kohl's function (/ (count coll) (reduce + (map /

Re: clojure.zip - throws exception

2010-02-25 Thread Sean Devlin
Hmm... what versions of Clojure (and other libs) are you using? Sean On Feb 24, 2:59 pm, Amitava Shee amitava.s...@gmail.com wrote: I am getting the following exception while trying to use clojure.zip user= (use '[clojure.zip :as zip]) java.lang.IllegalStateException: next already refers

Re: possible errors in ns documentation

2010-02-25 Thread Meikel Brandmeyer
Hi, On Feb 24, 10:17 pm, j1n3l0 nelo.ony...@googlemail.com wrote: (ns foo   (:use some.lib)) This works find for me. 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@googlegroups.com

Re: prn to a file with large data structures?

2010-02-25 Thread Meikel Brandmeyer
Hi, On Feb 25, 4:17 am, NovusTiro novust...@gmail.com wrote: I'm trying to prn a large data structure to a file so I can later read it back in, like so - (defn write-nick-sets [file-name obj]   (binding [*out* (java.io.FileWriter. file-name)]     (prn obj))) obj here is a map with a

Re: possible errors in ns documentation

2010-02-25 Thread Sean Devlin
What Clojure version are you using? On Feb 24, 4:17 pm, j1n3l0 nelo.ony...@googlemail.com wrote: Hi all, I'm not sure if this is the right place to raise this. I am new to clojure and was going through the docs for namespaces here:

Re: clojure.zip - throws exception

2010-02-25 Thread Meikel Brandmeyer
Hi, On Feb 24, 8:59 pm, Amitava Shee amitava.s...@gmail.com wrote: I am getting the following exception while trying to use clojure.zip user= (use '[clojure.zip :as zip]) java.lang.IllegalStateException: next already refers to: #'clojure.core/next in namespace: user (NO_SOURCE_FILE:0)

Re: prn to a file with large data structures?

2010-02-25 Thread Adrian Cuthbertson
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 back with; (defn rec-load Load a clojure form from file [#^File file] (with-open [r

Re: clojure.zip - throws exception

2010-02-25 Thread Tobias Hauth
Use require instead of use: (require '[clojure.zip :as zip]) Tobias On Wed, Feb 24, 2010 at 8:59 PM, Amitava Shee amitava.s...@gmail.comwrote: I am getting the following exception while trying to use clojure.zip user= (use '[clojure.zip :as zip]) java.lang.IllegalStateException: next

Re: Newbie suggestion for an implementation - rosettacode pythagorean means

2010-02-25 Thread Aviad Reich
thanks! On 25 February 2010 15:28, fra francesco.str...@gmail.com wrote: Hi, I have a small improvement. The function / called with only argument returns the inverse, so you can define g-mean and h-mean more shortly: (defn g-mean [coll] (expt (reduce * coll) (/ (count coll (defn

ANN: midi-clj and osc-clj

2010-02-25 Thread Jeff Rose
Just a quick announcement for any musical Clojurians out there. I've pushed midi-clj for simple MIDI communication, and osc-clj for communicating with new school instruments via Open Sound Control. Both were developed for project Overtone, but they might be useful for other projects. Get them

Re: Got a Clojure library?

2010-02-25 Thread Nurullah Akkaya
The name of your library clodiuno Library home page URL http://nakkaya.com/clodiuno.markdown Your name Nurullah Akkaya Category (db, web, UI, parsing etc) Physical Computing License Beerware Revision 42 A one-paragraph description. Include 3rd party dependencies if any. Clodiuno

Announce: Introductory article about Clojure in Russian

2010-02-25 Thread Alex Ott
Hi all In new issue of Russian FP journal (http://fprog.ru/) was published an article about Clojure (http://fprog.ru/2010/issue4/alex-ott-clojure/ - HTML, and http://fprog.ru/2010/issue4/ - different PDF sizes). This is introduction-level article, that could be used as basis for studying

Re: ANN: midi-clj and osc-clj

2010-02-25 Thread Anders Rune Jensen
On Thu, Feb 25, 2010 at 4:41 PM, Jeff Rose ros...@gmail.com wrote: Just a quick announcement for any musical Clojurians out there.  I've pushed midi-clj for simple MIDI communication, and osc-clj for communicating with new school instruments via Open Sound Control. Both were developed for

Re: Prefixed or suffixed symbols?

2010-02-25 Thread Jarkko Oranen
On Feb 25, 12:17 am, joshua-choi rbysam...@gmail.com wrote: When it comes to distinguishing certain types of symbols from other things, should one use prefixes or suffixes? Whichever makes more sense, of course. :) Example: naming tests with clojure.test/deftest. If you distinguish your

Re: Prefixed or suffixed symbols?

2010-02-25 Thread Daniel Werner
Hello Joshua, I don't think there is an official standard in Clojure, at least not yet. For a source of inspiration, you may be interested in this thread, in case you haven't found it yourself yet: http://groups.google.com/group/clojure-dev/browse_thread/thread/d090b5599909497c Personally, I

Re: ANN: midi-clj and osc-clj

2010-02-25 Thread Jeff Rose
Luckily there are already good Java libraries for doing all three of these: jlayer, jorvis and jflac. We will probably integrate these in with Overtone eventually, but for now we just use wav files for samples. -Jeff On Feb 25, 8:53 pm, Anders Rune Jensen anders.rune.jen...@gmail.com wrote: On

no source file

2010-02-25 Thread Glen Rubin
Hi, I wrote some code, put it in a file, and now want to load that file. Here is the code I wrote, sqrs.clj: (use '[clojure.contrib.generic.math-functions :only (sqr)]) (defn square-of-sum [coll] adds up collection of numbers and then squares it (sqr (reduce + coll)))

Re: no source file

2010-02-25 Thread Stephen C. Gilardi
On Feb 25, 2010, at 8:21 PM, Glen Rubin wrote: whenever I try (load-file sqrs.clj) i get a no source file exception. Does (load-file sqrs.clj) work? --Steve -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Vimclojure Performance on Windows

2010-02-25 Thread Vitaly Peressada
Installed vimclojure-2.1.2 on Windows XP SP3. Have dual-core machine and 4GB of RAM. In VimRepl (println Hello World) takes about 10 seconds. Is this expected? Any suggestions how to speed this up? -- You received this message because you are subscribed to the Google Groups Clojure group. To

let and nesting

2010-02-25 Thread kuniklo
One of my least favorite things about common lisp was the degree of nesting it required for sequential variable definitions. For common code like this: (let (a vala) (b valb) ... do something with a b... (let (c (fn a b)) (d (fn a b)) ... do something with a, b, c,

Re: clojure.zip - throws exception

2010-02-25 Thread Amitava Shee
Thank you - this really helped. To Sean's question - I am using 1.1.0 Just to solidify my understanding, can this be done in the default namespace (of user)? -Amitava On Feb 25, 9:50 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Feb 24, 8:59 pm, Amitava Shee amitava.s...@gmail.com wrote:

Re: possible errors in ns documentation

2010-02-25 Thread j1n3l0
Please forgive my mistake. I missed out a set of parentheses in there. It should be something like this: (ns foo (:use (some.lib))) There are othe scenarios of different use cases: ;; see link for example http://github.com/technomancy/leiningen/blob/master/src/lancet.clj (ns foo (:use

Re: let and nesting

2010-02-25 Thread Mike Meyer
On Thu, 25 Feb 2010 16:28:05 -0800 (PST) kuniklo milese...@gmail.com wrote: One of my least favorite things about common lisp was the degree of nesting it required for sequential variable definitions. For common code like this: (let (a vala) (b valb) ... do something with a

Re: Prefixed or suffixed symbols?

2010-02-25 Thread joshua-choi
Yeah, I don’t really like the underscores either. But I have to work with the set of currently allowed non-alphanumeric symbol characters (*, +, !, -, _, and ?, according to clojure.org/reader). There’s actually two different questions here—I’d love for other people to bring in their input. I

Re: Prefixed or suffixed symbols?

2010-02-25 Thread Sean Devlin
I think using a naming convention isn't a good idea, especially when you have a rich macro system like Clojure. I'm actually going to be talking about using a reference to handle things like this in my next episode. For now, you can take a look at my definference macro here:

Re: Prefixed or suffixed symbols?

2010-02-25 Thread joshua-choi
Could you explain more what you mean? For instance, how are macros related to these questions? This just has to do with informal naming conventions, in the same matter as *e or *print-dup*. Are you talking about that it’s possible for naming conventions to interfere with macros that interpret

Re: let and nesting

2010-02-25 Thread Adrian Cuthbertson
You can also do stuff in the middle of a let; (let [a vala b valb _ (do-something-with a b) c (some-fn a b) d (some-fn a b) _ (do-something a b c d) e (fn ...) f (fn )] (and-whatever-else)) Here _ is just some arbitrary unused variable. Note that

Re: Prefixed or suffixed symbols?

2010-02-25 Thread joshua-choi
Ah, yes, it is a. (The only thing that I anticipate a computer would use this for is different syntax highlighting. Actually, can any Clojure editors change symbols’ colors based on if they match a pattern like *a*?) Because Daniel Warner and Jarkko Oranen both said they think underscores are

Re: Prefixed or suffixed symbols?

2010-02-25 Thread Sean Devlin
Ah, case a is simpler, and I retract my macro suggestions. As to you question about editors, I know that it's possible to adapt emacs clojure-mode the change colors based on a regex. That's how it knows to color something pink for a fn in clojure.core, and green for a fn in the standard library

ClojureCLR status?

2010-02-25 Thread Mike K
I notice there have been no checkins to ClojureCLR in the last month and a half. Is something big in the works? Is absolutely nothing in the works? :-) If I check out and build the latest sources, how will it compare in terms of functionality to the Clojure main branch? In particular, does it

Re: let and nesting

2010-02-25 Thread kuniklo
On Feb 25, 7:50 pm, Adrian Cuthbertson adrian.cuthbert...@gmail.com wrote: You can also do stuff in the middle of a let; (let [a vala       b valb       _ (do-something-with a b)       c (some-fn a b)       d (some-fn a b)       _ (do-something a b c d)       e (fn ...)       f (fn

Re: Vimclojure Performance on Windows

2010-02-25 Thread Meikel Brandmeyer
Hi, On Feb 25, 4:46 pm, Vitaly Peressada vit...@ufairsoft.com wrote: Installed vimclojure-2.1.2 on Windows XP SP3. Have dual-core machine and 4GB of RAM. In VimRepl (println Hello World) takes about 10 seconds. Is this expected? No. Vim shells out to another process. This is the only real

Re: clojure.zip - throws exception

2010-02-25 Thread Meikel Brandmeyer
Hi, On Feb 25, 4:19 pm, Amitava Shee amitava.s...@gmail.com wrote: Just to solidify my understanding, can this be done in the default namespace (of user)? Yes. Instead of (ns foo.bar (:require [clojure.zip :as zip])) when setting up the foo.bar namespace you can just use require in the user

Re: no source file

2010-02-25 Thread Konrad Hinsen
On 26 Feb 2010, at 02:21, Glen Rubin wrote: Here is the code I wrote, sqrs.clj: (use '[clojure.contrib.generic.math-functions :only (sqr)]) (defn square-of-sum [coll] adds up collection of numbers and then squares it (sqr (reduce + coll))) A different point: if you can

Re: order of function definition

2010-02-25 Thread Laurent PETIT
Hi, 2010/2/25 Meikel Brandmeyer m...@kotka.de Hi, On Feb 25, 11:24 am, reynard atsan...@gmail.com wrote: I define a function foo in which it calls an auxiliary function bar, which is not yet defined, and a compiler exception is raised claiming unable to resolve symbol bar. Is there