Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread gary ng
On Wed, May 5, 2010 at 10:34 PM, Meikel Brandmeyer wrote: > I'm deeply suspicious of such a behaviour. Why would + on a > date mean adding days? Why not hours? minutes? seconds? > months? years? I would always prefer plus-days over such a > behaviour, because I wouldn't have to think everytime, w

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Richard Newman
(+ today (- 14 remind-prior)) => 2 weeks from today - a fixed remind before days => a date when I am going to be reminded for an event 2 weeks from today I'm deeply suspicious of such a behaviour. Why would + on a date mean adding days? Frink (as one example) resolves this through unit track

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Meikel Brandmeyer
Hi, On 6 Mai, 03:38, gary ng wrote: > I am writing a toy DSL where I would like it to be able to do something like > this: > > (+ today 3) => a date which is 3 days from today > (+ 1 2) => 3 > > such that the following is possible > > (+ today (- 14 remind-prior)) > => 2 weeks from today - a fix

Re: Mahout in Clojure

2010-05-05 Thread ataggart
Wow! What hoops one has to jump through to fit things in an "OO" API, eh? Anyway, if you're using 1.2: (reify RecommenderBuilder (buildRecommender [this model] (let [similarity (PearsonCorrelationSimilarity. model) neighborhood (NearestNUserNeighborhood. 2 similarity model)]

Re: removing the need for refer-clojure ?

2010-05-05 Thread joshua-choi
I would love if this happened; it could probably be implemented in a backwardly compatible way, since you're currently not supposed to use or require clojure.core anyway, as far as I know. On May 5, 8:36 am, Laurent PETIT wrote: > Hello, > > After thinking twice about it, ns does 2 special things

Re: Mahout in Clojure

2010-05-05 Thread Krukow
On May 5, 2:40 pm, klathrop wrote: [snip] > Its the RecommenderBuilder that's giving me trouble.  I've tried using > proxy with no luck.  Any suggestions? Can you post the code that fails? /Karl -- You received this message because you are subscribed to the Google Groups "Clojure" group. To po

Re: removing the need for refer-clojure ?

2010-05-05 Thread Per Vognsen
Here's how it works with Haskell: The Prelude module is imported automatically into all modules as if by the statement `import Prelude', if and only if it is not imported with an explicit import declaration. This provision for explicit import allows values defined in the Prelude to

Re: removing the need for refer-clojure ?

2010-05-05 Thread ataggart
Sounds reasonable to me... which probably means there's some problematic detail I cannot see but which will seem entirely obvious when Rich points it out. On May 5, 8:36 am, Laurent PETIT wrote: > Hello, > > After thinking twice about it, ns does 2 special things for clojure.core > today: > 1. i

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread gary ng
On Wed, May 5, 2010 at 3:18 PM, Meikel Brandmeyer wrote: > Hi, > > On Wed, May 05, 2010 at 02:56:09PM -0700, gary ng wrote: > Right now, this can be handled as: > > (ns foo > (:refer-clojure :as core :exclude (+))) > > (defn + > [matrix1 matrix2] > ... (core/+ num1 num2) ...) > > > Thanks. tho

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Chas Emerick
On May 5, 3:47 pm, Meikel Brandmeyer wrote: > Hi, > > On Wed, May 05, 2010 at 08:24:39AM -0700, Chas Emerick wrote: > > variety of birds with one stone, and maybe slightly simplify the > > mental model that one needs to have in place to understand namespaces. > > The model is already quite easy, n

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Meikel Brandmeyer
Hi, On Wed, May 05, 2010 at 02:56:09PM -0700, gary ng wrote: > I have a question related to this. > > (ns foo (:use clojure.core)) > > (defn + [x y] x) > > '+' is already referred because of the use and is an error right now. But > this is a legitimate use of the symbol as 'foo' can be matrix

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread gary ng
I have a question related to this. (ns foo (:use clojure.core)) (defn + [x y] x) '+' is already referred because of the use and is an error right now. But this is a legitimate use of the symbol as 'foo' can be matrix and matrix addition is different from standard number addition. Or is there a b

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Meikel Brandmeyer
Hi, On Wed, May 05, 2010 at 11:08:26PM +0200, Laurent PETIT wrote: > But it's not worse than writing a new version of a macro and > forgetting to recompile all the code depending directly or indirectly > on the macro ... Or redefining a defmulti loosing the methods. This was supposed to be addre

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Laurent PETIT
2010/5/5 Meikel Brandmeyer : > Hi Laurent, > > On Wed, May 05, 2010 at 10:12:52PM +0200, Laurent PETIT wrote: > >> > The question with the new style is: to which filter does f refer to? >> > >> > (ns some.name.space) >> > >> > (defn f [pred x] (filter pred x)) ; core filter? >> > >> > (defn filter

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Meikel Brandmeyer
Hi Laurent, On Wed, May 05, 2010 at 10:12:52PM +0200, Laurent PETIT wrote: > > The question with the new style is: to which filter does f refer to? > > > > (ns some.name.space) > > > > (defn f [pred x] (filter pred x)) ; core filter? > > > > (defn filter [pred x] ...) > > I bet on core filter, s

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Laurent PETIT
Hi, 2010/5/5 Meikel Brandmeyer : > Hi, > > On Wed, May 05, 2010 at 08:24:39AM -0700, Chas Emerick wrote: > >> variety of birds with one stone, and maybe slightly simplify the >> mental model that one needs to have in place to understand namespaces. > > The model is already quite easy, no? Everythi

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Meikel Brandmeyer
Hi, On Wed, May 05, 2010 at 08:24:39AM -0700, Chas Emerick wrote: > variety of birds with one stone, and maybe slightly simplify the > mental model that one needs to have in place to understand namespaces. The model is already quite easy, no? Everything is just a sequence of statements read by C

Re: lazy-seq question

2010-05-05 Thread Meikel Brandmeyer
Hi, On Wed, May 05, 2010 at 08:17:51AM -0700, Robert Luo wrote: > > repeated-seq cannot do anything about the problem. You have to ensure > > that your f is free of "overlap" (so to say). One way todo that in > > your example is (repeated-seq #(-> % inc (range 5)) -1). > > In my example function

Re: ?: promotion of integral types

2010-05-05 Thread alux
Thank you for the discussion - even if I dont understand it immediately ;-) Grettings, alux On 5 Mai, 17:32, David Nolen wrote: > On Wed, May 5, 2010 at 11:11 AM, Sean Devlin wrote: > > > I think there's a fundamental assumption that I disagree with. > > > Since we've already opened the can of w

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Sean Devlin
+1 after 1.2 On May 5, 11:24 am, Chas Emerick wrote: > We've been able to treat ns declarations *as* declarations for the > most part, which is nice.  IMO, last-var-wins pulls the veil away even > more on the fact that namespaces are probably the most pervasively- > stateful part of clojure. > >

Re: labrepl: kl...@feersum:~/projects/labrepl$ script/repl java.lang.ExceptionInInitializerError (control.clj:9)

2010-05-05 Thread Greg Brown
I just checked both maven and netbeans and they seem to be working properly. Thanks! On Wed, May 5, 2010 at 7:37 AM, Stuart Halloway wrote: > I just pushed a change to pom.xml, can maven folks please test? > > Make sure that you are getting todays' contrib build! > >> I'm seeing this as well. >

removing the need for refer-clojure ?

2010-05-05 Thread Laurent PETIT
Hello, After thinking twice about it, ns does 2 special things for clojure.core today: 1. if no mention of clojure.core (indirectly via refer-clojure), consider that clojure.core must entirely be 'use d in the namespace 2. if refer-clojure is used, bypass 1. and do whatever is in refer-clojure wh

Re: ?: promotion of integral types

2010-05-05 Thread David Nolen
On Wed, May 5, 2010 at 11:11 AM, Sean Devlin wrote: > I think there's a fundamental assumption that I disagree with. > > Since we've already opened the can of worms that is auto-promotion, it > should *always* work. Given auto-promotion, + shouldn't be fast (use > unchecked-add), it should be pre

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Chas Emerick
We've been able to treat ns declarations *as* declarations for the most part, which is nice. IMO, last-var-wins pulls the veil away even more on the fact that namespaces are probably the most pervasively- stateful part of clojure. I remember various proposals floating around a long time ago to lo

Re: lazy-seq question

2010-05-05 Thread Robert Luo
On 5月5日, 下午9时43分, Krukow wrote: > On May 5, 2:54 pm, Robert Luo wrote: > [snip] > > > (repeated-seq #(range % 5) 0) > > > the elements are:0 1 2 3 4 4 5 6 7 8 8... > > I think you mean, > > (def s (repeated-seq #(range % (+ % 5)) 0) ) Nope. The code is what I want to do. The repeated-seq is go

Re: lazy-seq question

2010-05-05 Thread Robert Luo
Thanks Meikel. On 5月5日, 下午9时40分, Meikel Brandmeyer wrote: > Hi, > > On 5 Mai, 14:54, Robert Luo wrote: > > > (defn repeated-seq > > [f start] > > (let [coll (f start)] > > (concat coll (lazy-seq (repeated-seq f (last coll)) > > > it is OK when I call it with: > > (repeated-seq #(rang

Re: labrepl updated

2010-05-05 Thread David Edgar Liebke
Let me know if you need me to make any changes. David On Wed, May 5, 2010 at 9:13 AM, Stuart Halloway wrote: > I'll have a fix up within a half hour that should require *no* changes to > incanter. > >> On 5 May 2010 14:26, Craig Andera wrote: >>> I have updated the labrepl [1] to use the l

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Meikel Brandmeyer
Hi, +1 for this change! I often start putting functions in a namespace, trying around in the Repl and then refactoring stuff out into other namespaces. But the original functions are still in place. Evaluating the first namespace often blows up with the "already there" error. So I have to manually

Re: ?: promotion of integral types

2010-05-05 Thread Sean Devlin
I think there's a fundamental assumption that I disagree with. Since we've already opened the can of worms that is auto-promotion, it should *always* work. Given auto-promotion, + shouldn't be fast (use unchecked-add), it should be predictable. Same for -, * and friends. Quality is more importan

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Douglas Philips
On 2010 May 5, at 10:32 AM, Stuart Halloway wrote: A SIMPLER SOLUTION: WARN, DON'T ERR That's a lot better than being dead with an error. Is there a way to turn those warnings back into errors for those really paranoid of us? PROMOTION AND DEPRECATION With "warn on nam

Re: ?: promotion of integral types

2010-05-05 Thread David Nolen
On Wed, May 5, 2010 at 10:32 AM, Sean Devlin wrote: > And I was too quick to post. Sorry about that. > > You've got the unchecked addition fn for speed, and those are allowed > the throw overflow errors. The + fn is always supposed to work. The > fact that it auto-promotes the bound version is

Re: Help with error...

2010-05-05 Thread Tassilo Horn
On Wednesday 05 May 2010 04:34:04 venkat wrote: > when i use this on single values, it works, but doesnt if i try to use > it over a lazy sequence > > user> (take 3 (mulseq (iterate inc 5))) > ; Evaluation aborted. > > clojure.lang.Cons cannot be cast to java.lang.Character > [Thrown class jav

Re: Help with error...

2010-05-05 Thread venkat
I found out how to make it work - mulseq expects int while iterate produces a list, so I have to map it on to the elements from iterate. however, can someone explain the error? thanks! On May 4, 10:34 pm, venkat wrote: > i have a function that returns a seq of sets, each containing the > digits

Help with error...

2010-05-05 Thread venkat
i have a function that returns a seq of sets, each containing the digits corresponding to the multiples (2x...6x) for a given number like so: (defn mulseq [n] (let [n (int n)] (map #(set (str (* n %))) [2 3 4 5 6]))) user> (mulseq 24) => (#{\4 \8} #{\2 \7} #{\6 \9} #{\0 \1 \2} #{\1 \4}) (mulseq

Re: labrepl: kl...@feersum:~/projects/labrepl$ script/repl java.lang.ExceptionInInitializerError (control.clj:9)

2010-05-05 Thread Stuart Halloway
I just pushed a change to pom.xml, can maven folks please test? Make sure that you are getting todays' contrib build! I'm seeing this as well. I think the problem is that the dependencies in the project.clj are pinned to compatible versions of the clojure and clojure-contrib jars, but not so i

Mahout in Clojure

2010-05-05 Thread klathrop
I'm working through "Mahout in Action", but using Clojure instead of Java,, and I'm having trouble using an interface in the Mahout library. The example is as follows: DataModel model = new FileDataModel(new File("intro.csv")); RecommenderEvaluator evaluator = new AverageAbsoluteDifferenceRecom

Re: Help: Rephrasing an English statement into questions.

2010-05-05 Thread Rick Mouritzen
Search online for "natural language processing". It's a big area. http://en.wikipedia.org/wiki/Category:Natural_language_processing On Mon, May 3, 2010 at 7:19 PM, JT wrote: > I need to write a program that will rephrase an English statement into > a question as many different ways as possible.

Re: labrepl: kl...@feersum:~/projects/labrepl$ script/repl java.lang.ExceptionInInitializerError (control.clj:9)

2010-05-05 Thread Greg Brown
I'm seeing this as well. I think the problem is that the dependencies in the project.clj are pinned to compatible versions of the clojure and clojure-contrib jars, but not so in the pom.xml. So anything using project.clj (just leiningen?) will work, but anything that tries to use the pom directly

last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Stuart Halloway
For a long time, people have been suggesting that various libraries be promoted from contrib into clojure core. Last week, we started making some of the necessary code changes. THE PROBLEM While the changes to Clojure itself are only additive and non- breaking, they can nevertheles

Re: ?: promotion of integral types

2010-05-05 Thread Sean Devlin
And I was too quick to post. Sorry about that. You've got the unchecked addition fn for speed, and those are allowed the throw overflow errors. The + fn is always supposed to work. The fact that it auto-promotes the bound version is proof. It needs to work with the literal, too. It's a Clojur

Re: ?: promotion of integral types

2010-05-05 Thread Sean Devlin
When this doesn't work: (= (+ Integer/MAX_VALUE Integer/MAX_VALUE) (+ Integer/MAX_VALUE Integer/MAX_VALUE 0)) You have a bug. On May 5, 9:38 am, AlexK wrote: > That's a wierd behviour, but it never produces incorrect results (it > throws an exception when it would). > > the two-argument ver

Re: lazy-seq question

2010-05-05 Thread Krukow
On May 5, 2:54 pm, Robert Luo wrote: [snip] > (repeated-seq #(range % 5) 0) > > the elements are: 0 1 2 3 4 4 5 6 7 8 8 ... I think you mean, (def s (repeated-seq #(range % (+ % 5)) 0) ) > However, I want to get rid of the duplicated index element (4, 8 etc), > e.g. > To produce 0 1 2 3 4 5

Re: lazy-seq question

2010-05-05 Thread Meikel Brandmeyer
Hi, On 5 Mai, 14:54, Robert Luo wrote: > (defn repeated-seq >   [f start] >   (let [coll (f start)] >     (concat coll (lazy-seq (repeated-seq f (last coll)) > > it is OK when I call it with: > (repeated-seq #(range % 5) 0) repeated-seq cannot do anything about the problem. You have to ensu

Re: lazy-seq question

2010-05-05 Thread Sean Devlin
Where are you inserting the rest? Can you post the new form? On May 5, 8:54 am, Robert Luo wrote: > I wrote a function as: > > (defn repeated-seq >   [f start] >   (let [coll (f start)] >     (concat coll (lazy-seq (repeated-seq f (last coll)) > > it is OK when I call it with: > (repeated-se

Re: ?: promotion of integral types

2010-05-05 Thread AlexK
That's a wierd behviour, but it never produces incorrect results (it throws an exception when it would). the two-argument versions of + - * / get inlined to a static method call. Either to a static method which accepts unboxed primitives or one that accepts their boxed variants. The problem is tha

Re: labrepl updated

2010-05-05 Thread Stuart Halloway
I'll have a fix up within a half hour that should require *no* changes to incanter. On 5 May 2010 14:26, Craig Andera wrote: I have updated the labrepl [1] to use the latest clojure 1.2 and contrib 1.2 snapshots. Also, most of the dependencies are now frozen to specific snapshot timestam

Re: labrepl updated

2010-05-05 Thread Michael Wood
On 5 May 2010 14:26, Craig Andera wrote: > > > I have updated the labrepl [1] to use the latest clojure 1.2 and contrib 1.2 > > snapshots. Also, most of the dependencies are now frozen to specific > > snapshot timestamps (the project.clj file may be of interest to people > > living > > on the dev

Re: labrepl updated

2010-05-05 Thread Stuart Halloway
Nevermind, I am seeing what Craig sees. Found the issue and am on it. Stu Against the same commit I just did: lein clean; lein deps. After which both script/repl and script/swank run fine (albeit with lots of the new "WARNING: group-by already refers to:") warnings. Here's exactly what "le

lazy-seq question

2010-05-05 Thread Robert Luo
I wrote a function as: (defn repeated-seq [f start] (let [coll (f start)] (concat coll (lazy-seq (repeated-seq f (last coll)) it is OK when I call it with: (repeated-seq #(range % 5) 0) the elements are: 0 1 2 3 4 4 5 6 7 8 8 ... However, I want to get rid of the duplicated index el

Re: labrepl updated

2010-05-05 Thread Stuart Halloway
Against the same commit I just did: lein clean; lein deps. After which both script/repl and script/swank run fine (albeit with lots of the new "WARNING: group-by already refers to:") warnings. Here's exactly what "lein deps" installed in the lib. Craig: do you see the same? -rw-r--r-- 1

Re: Clojure 1.2 slides anyone?

2010-05-05 Thread Sean Devlin
We're working on the release notes now. Nothing finished yet. It'll probably be a couple more weeks until it's done. On May 5, 6:38 am, Michael Kohl wrote: > Hi all, > > just wondering if someone has a ready presentation on Clojure 1.2 > lying around that I can (partly) use at the next meeting

Re: ?: promotion of integral types

2010-05-05 Thread Sean Devlin
Yeah, I just reproduced this. I think it's a bug. Created Assembla ticket 339. I've added some more test cases their too. Thanks! Sean On May 5, 3:15 am, alux wrote: > Hello, > > can somebody please explain the difference between the following two? > > (def imax (Integer/MAX_VALUE)) > (+ imax

Re: labrepl updated

2010-05-05 Thread Craig Andera
> I have updated the labrepl [1] to use the latest clojure 1.2 and contrib 1.2 > snapshots. Also, most of the dependencies are now frozen to specific > snapshot timestamps (the project.clj file may be of interest to people living > on the development edge). > > After a "lein clean;  lein deps" ever

RFC: my use of protocols and datatypes

2010-05-05 Thread Krukow
For those of you who are interested and have a few spare minutes: I have a request for comments/feedback on my (first) use of protocols and datatypes (and of my Clojure programming too :-) I've written a functional implementation of Michael Nygaards circuit breaker stability pattern. Code at gith

Clojure 1.2 slides anyone?

2010-05-05 Thread Michael Kohl
Hi all, just wondering if someone has a ready presentation on Clojure 1.2 lying around that I can (partly) use at the next meeting of our functional programming user group? If not I'll probably whip something up myself based on Assembla [1], but I'd rather save myself the trouble... Thanks, Micha

?: promotion of integral types

2010-05-05 Thread alux
Hello, can somebody please explain the difference between the following two? (def imax (Integer/MAX_VALUE)) (+ imax imax) gives 4294967294 but (+ (Integer/MAX_VALUE) (Integer/MAX_VALUE)) results in integer overflow [Thrown class java.lang.ArithmeticException] Shouldnt this be the same? T