Re: a macro

2010-10-12 Thread Laurent PETIT
2010/10/13 Sunil S Nandihalli > as a follow up with further clarifications, I would like to mention that > Variables is already a predefined macro and I don't want have to execute it > at run-time since it uses mathematica and we cannot distribute mathematica > to the end user. > > and also pleas

Re: a macro

2010-10-12 Thread Meikel Brandmeyer
Hi, On 13 Okt., 07:55, Sunil S Nandihalli wrote: > I know if is a function and will not be evaluated before the macro expands.. > may be there is a way to wrap it in a macro (since f is already defined > which I would like to use) and have the macro Variables apply on the result > of evaluation

Re: a macro

2010-10-12 Thread Robert McIntyre
I'm still a little confused as to what you're trying to do, but is this what you're looking for? (defmacro zzz [form] (first form)) (defmacro eval-zzz [form] `(zzz ~(eval form))) rlm.play-all> (zzz (range 1 2)) # rlm.play-all> (macroexpand-1 '(eval-zzz (range 5))

Re: a macro

2010-10-12 Thread Sunil S Nandihalli
as a follow up with further clarifications, I would like to mention that Variables is already a predefined macro and I don't want have to execute it at run-time since it uses mathematica and we cannot distribute mathematica to the end user. and also please read my last sentence as I know f is a f

Re: Creating a new library

2010-10-12 Thread Saul Hazledine
On Oct 13, 5:31 am, lprefonta...@softaddicts.ca wrote: > As far a publishing to Clojars, I do not know the policy. > Uploading various jars maintained by other teams not involved in > Clojure may "pollute" the repo along the way. > As I understand it, its fine to put jars from other projects on Cl

a macro

2010-10-12 Thread Sunil S Nandihalli
Hello Everybody, I think I was not clear about things in my previous email.. I am reposting simplifying things... Variables is a macro which works in the following way.. (Variables (+ x (* 2 y)) returns [x y] now let us say we have a function (defn f [] '(+ x (* 2 y))) now I would like to

Re: evaluation of a function via mathematica from clojure using the clojuratica bridge...

2010-10-12 Thread Sunil S Nandihalli
Thanks Garth.. That works well .. mathematica->clojure function has been quiet usefull. Sorry for the delayed response.. Sunil. On Fri, Oct 8, 2010 at 9:54 AM, Garth Sheldon-Coulson wrote: > Sorry, the Needs call isn't quite right. Do this instead: > > << ClojurianScopes` > > Garth > > > On Fri,

Re: Creating a new library

2010-10-12 Thread lprefontaine
Normally the people maintaining the Minim project should publish their stuff in a maven public repo. There are the ones in control of their releases. As far a publishing to Clojars, I do not know the policy. Uploading various jars maintained by other teams not involved in Clojure may "pollute" the

Re: Creating a new library

2010-10-12 Thread Nurullah Akkaya
For each non-clojure jar file you have, you need to create a pom.xml file using the instructions here, http://github.com/ato/clojars-web/wiki/POM and scp the pom file and the jar to clojars, then you can include them in your project.clj. So if Minim.jar depends on A.jar, B.jar, upload A.jar and

Re: Creating a new library

2010-10-12 Thread Vilson Vieira
2010/10/12 > a) Assuming all the dependencies are published in a maven repo out there: > > If you put all your deps in project.clj, the pom.xml file generated by > leiningen will reference all of them as dependencies to your own lib. > You only need to publish your own library and the pom.xml

Re: Help to optimize palindrome search from input file

2010-10-12 Thread pkw
I'm just replying because I also do this in clojure and my level is also really slow: http://github.com/krsanky/greplin-challenge/blob/master/greplin-challenge/src/greplin_challenge/level1.clj :) --paul wisehart -- You received this message because you are subscribed to the Google Groups "Cloj

Re: Problems with clojure couchdb

2010-10-12 Thread Mark Engelberg
On Tue, Oct 12, 2010 at 6:41 AM, Moritz Ulrich wrote: > Regarding your error: Maybe you open too many sockets which don't get > closed and your process runs out of file descriptors. Yes, I think that's the problem. I found a blurb on the net about how to expand the range of usable ports for sock

Re: Creating a new library

2010-10-12 Thread lprefontaine
a) Assuming all the dependencies are published in a maven repo out there: If you put all your deps in project.clj, the pom.xml file generated by leiningen will reference all of them as dependencies to your own lib. You only need to publish your own library and the pom.xml to Clojars. Anyo

Re: strange bug in range or lazy-seq?

2010-10-12 Thread Paul Mooser
Any chance someone could walk us through how this visibility issue occurs (where the range-based version of primes consumes numbers before they are visible). This really looks like a case where side effects and implementation details are causing what appear to be strange behaviors, based on multipl

Re: precise numbers

2010-10-12 Thread Mike Meyer
On Tue, 12 Oct 2010 17:44:20 -0400 Brian Hurt wrote: > On Tue, Oct 12, 2010 at 3:35 PM, cej38 wrote: > > > The more that I think about it, the more I would rather have a set of > > equalities that always work. float= was a good try. > Maybe initially, but not later on... > Floating point is

Creating a new library

2010-10-12 Thread Vilson Vieira
Hello, I want to create a Clojure wrapper for Minim and push to clojars. So I have a bunch of jar files from Minim as deps and I want to put them on my lib/. How can I add a non-clojure jar file on my lein project? Or I need to create a specific lein project for every jar? Like there's a process

Re: precise numbers

2010-10-12 Thread Brian Hurt
On Tue, Oct 12, 2010 at 3:35 PM, cej38 wrote: > The more that I think about it, the more I would rather have a set of > equalities that always work. float= was a good try. > > > Every fucking language I've ever worked on has had this problem- "floats are broken!" And every single one, people

Re: Help to optimize palindrome search from input file

2010-10-12 Thread tonyl
I new the palindrome? function wasn't good in performance, but I didn't think it would be that bad. The type hinting does improve performance plus a mid way to compare. Thanks for pointing that out and the max-key function. On Oct 12, 4:15 pm, Justin Kramer wrote: > The 'palindrome?' function can

Re: Help to optimize palindrome search from input file

2010-10-12 Thread Justin Kramer
The 'palindrome?' function can be made much faster. Your version -- which is idiomatic and fine when perf isn't a factor -- turns the test string into a sequence, reverses it, turns it back into a string, then checks for full equality with the original. There are faster (if uglier) ways to check fo

Re: error on a project using clj-processing

2010-10-12 Thread Vilson Vieira
2010/10/12 Stephen C. Gilardi > That may be related to having compiled code from different versions of > Clojure trying to mix. Do you know what the deps of rosado.processing are? > It may help to use clojure and contrib 1.2.0 rather than snapshots. > Thanks Steve. I've pushed a new rosado.proc

Re: Help to optimize palindrome search from input file

2010-10-12 Thread tonyl
So for returns a lazy-seq of the combinations and I am forcing it to process the values by filtering. mmm... I still tried your approach and nothing changed in processing time. I changed the for form to filter as it is pairing the combinations, I didn't think it would make any difference since I ju

Re: Test-driven development in Clojure

2010-10-12 Thread Armando Blancas
> Back to my question: Am I trying to do Java in Clojure? Is there a more > Lisp-y way to do this? You can hide the types so your client code is more lispy: (defn load-page [prov] (.loadPage prov)) ;;test (def mp (make-mock-provider)) ... (load-page mp) ;;production (def prov (make-provider)) ...

Re: precise numbers

2010-10-12 Thread Mike Meyer
On Tue, 12 Oct 2010 12:35:24 -0700 (PDT) cej38 wrote: > The more that I think about it, the more I would rather have a set of > equalities that always work. float= was a good try. Then you can't use floats. As others have explained, floats are imprecise by nature, being limited to finite binar

Re: Help to optimize palindrome search from input file

2010-10-12 Thread Sean Grove
I actually played with this on Saturday morning while waiting for a friend, and thought it was an interesting problem. Your example is spending most of its time filtering with palindrome? across all 682695 items generated by all-combs. To see, try: (defn tony [] (def source "I like racecars t

Re: precise numbers

2010-10-12 Thread David Sletten
I suggest you read the article a bit more closely. Here are the details of your specific case. The number that you are typing as 12.305 is actually being stored in the computer as this: 1100.010011110100001011110100001011100 This number is actually this fraction: 173177479421231

Re: precise numbers

2010-10-12 Thread cej38
The more that I think about it, the more I would rather have a set of equalities that always work. float= was a good try. -- 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 fr

Re: precise numbers

2010-10-12 Thread Angel Java Lopez
Short comment: I remember Common Lisp has rational numbers (I'm not sure). Any rational number library for Clojure? Angel "Java" Lopez http://www.ajlopez.com http://twitter.com/ajlopez On Tue, Oct 12, 2010 at 4:14 PM, Luka Stojanovic wrote: > On Tue, 12 Oct 2010 20:53:16 +0200, cej38 wrote:

Re: precise numbers

2010-10-12 Thread Luka Stojanovic
On Tue, 12 Oct 2010 20:53:16 +0200, cej38 wrote: On Oct 12, 12:50 pm, David Sletten wrote: This discussion may help:http://www.gettingclojure.com/cookbook:numbers#comparing-floats I originally tried something like float= described in the link, I give the definition here (defn float= ([x

Help to optimize palindrome search from input file

2010-10-12 Thread tonyl
Hi, I just started to learn clojure in a more serious way and I am doing the first level of the greplin challenge. I made it to work with a short palindrome like the example they give me, but when it comes to work with the input file, it takes for ever and I have to stop it. $ time clj level1.clj

Re: precise numbers

2010-10-12 Thread cej38
On Oct 12, 12:50 pm, David Sletten wrote: > This discussion may > help:http://www.gettingclojure.com/cookbook:numbers#comparing-floats I originally tried something like float= described in the link, I give the definition here (defn float= ([x y] (float= x y 0.1)) ([x y epsilon] (le

Re: precise numbers

2010-10-12 Thread Nicolas Oury
If you want to be really precise, most real numbers are an infinite number of decimals. If you encode them as a lazy seq of decimals, + - and other ops are doable. Comparison is semi-decidable only: it terminates only in certain case (finite number of decimals) or when the number are different. b

Re: precise numbers

2010-10-12 Thread ataggart
Welcome to floating point math. As an alternative, try using arbitrary-precision numerics: user=> (- 12.305M 12.3049M) 0.0001M user=> (type *1) java.math.BigDecimal On Oct 12, 9:17 am, cej38 wrote: > I keep running into this type of problem: > > user=> (- 12.305 12.3049) > 9.9976694E-5

Re: precise numbers

2010-10-12 Thread Felix H. Dahlke
Um, I meant BigDecimal, not BigInteger. On 12/10/10 18:24, Felix H. Dahlke wrote: > You could use BigInteger, which was created to work around double's > rounding issues - among other things. > > (- 12.305M 12.3049M) > 0.0001M > > On 12/10/10 18:17, cej38 wrote: >> I keep running into this type

Re: Test-driven development in Clojure

2010-10-12 Thread Felix H. Dahlke
The posts and Midje looks pretty interesting, but I'm not sure if I was able to follow, being new to Clojure. I'll give it another try later :) Meanwhile, I've adjourned TDD in my project and wrote some code without it to see if it makes more sense to me that way. I have to say that, although I di

Re: Test-driven development in Clojure

2010-10-12 Thread Brian Marick
On Oct 12, 2010, at 8:59 AM, Kyle R. Burton wrote: > > Does Midje integration with the usual test lifecycle for maven and Leiningen? If you type 'lein test', it'll run the Midje tests, but it doesn't hook into the reporting system (so you get 0 tests run, 0 failures reported). I want to see if

Re: strange bug in range or lazy-seq?

2010-10-12 Thread Stuart Halloway
Sorry, that should have been (def primes (concat [2] (lazy-seq (let [primes-from (fn primes-from [n] (if (some #(zero? (rem n %)) (take-while #(<= (* % %) n) primes)) (recur (+ n 2)) (lazy-seq (cons n (primes-fro

Re: precise numbers

2010-10-12 Thread Alan
Also see (rationalize) to simplify my example of using ratios. I couldn't remember the name of the function off the top of my head, so I used a hacked-up-by-me version. On Oct 12, 9:33 am, Alan wrote: > The JVM has no choice: it must faithfully implement the IEEE floating- > point spec (http://en

Re: Test-driven development in Clojure

2010-10-12 Thread Stuart Sierra
Datatypes that implement a single method can be more simply represented as ordinary functions, e.g. (defn real-provider ...) (defn fake-provider ...) (defn load-page [provider ...] (let [foo (provider)] ...)) That being said, you have other options: In clojure.test you can using `binding` to

Re: precise numbers

2010-10-12 Thread David Sletten
This discussion may help: http://www.gettingclojure.com/cookbook:numbers#comparing-floats Have all good days, David Sletten On Oct 12, 2010, at 12:17 PM, cej38 wrote: > I keep running into this type of problem: > > user=> (- 12.305 12.3049) > 9.9976694E-5 > > The computer (probably the

Re: strange bug in range or lazy-seq?

2010-10-12 Thread SpiderPig
Thank you all for explaining this to me but I still don't understand clojures behavior in this case, Try running this code: (def nums (drop 2 (range))) (def primes (cons (first nums) (lazy-seq (->> (rest nums) (remove (fn [x]

Re: precise numbers

2010-10-12 Thread Alan
The JVM has no choice: it must faithfully implement the IEEE floating- point spec (http://en.wikipedia.org/wiki/IEEE_754-2008), which specifies limited precision. By asking it to use floats, you are demanding that it accept rounding errors. If you want precision, there are lots of ways to get it; t

Re: precise numbers

2010-10-12 Thread David Nolen
On Tue, Oct 12, 2010 at 12:17 PM, cej38 wrote: > I keep running into this type of problem: > > user=> (- 12.305 12.3049) > 9.9976694E-5 http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm David -- You received this message because you are subscribed to the Googl

Re: precise numbers

2010-10-12 Thread Felix H. Dahlke
You could use BigInteger, which was created to work around double's rounding issues - among other things. (- 12.305M 12.3049M) 0.0001M On 12/10/10 18:17, cej38 wrote: > I keep running into this type of problem: > > user=> (- 12.305 12.3049) > 9.9976694E-5 > > The computer (probably the

precise numbers

2010-10-12 Thread cej38
I keep running into this type of problem: user=> (- 12.305 12.3049) 9.9976694E-5 The computer (probably the JVM) has just lied to me. Any fourth grade student will know that this does not equal 0.0001. This would be less of a problem is the JVM was consistent; if it were consistent then

Re: Clojars SSH key change?

2010-10-12 Thread Phil Hagelberg
On Tue, Oct 12, 2010 at 5:43 AM, Saul Hazledine wrote: > I'm guessing the server has been moved/upgraded but I thought it best > to check since I couldn't see a notice of this anywhere. This is correct; Clojars is now hosted on a new machine. Along with the change of hardware comes the ability fo

Re: strange bug in range or lazy-seq?

2010-10-12 Thread Jason Wolfe
On Oct 11, 6:56 pm, Stuart Halloway wrote: > When a var's definition has a "lazy reference" to itself, as primes does > below, then your results will be dependent on the lazy/chunky/strict-ness of > the calls leading to the lazy reference. While I agree that this sort of reference is probably

Re: strange bug in range or lazy-seq?

2010-10-12 Thread babui
On 12 oct, 03:56, Stuart Halloway wrote: I've tried your definition > (def primes >   (concat >    [2] >    (let [primes-from >          (fn primes-from >            [n] >            (if (some #(zero? (rem n %)) >                      (take-while #(<= (* % %) n) primes)) >              (recur (+

Re: Test-driven development in Clojure

2010-10-12 Thread Kyle R. Burton
>> For another point of view: take a look at what Brian Marick's been >> doing with a framework called Midje to do outside-in TDD. It helps you >> mock out function dependencies and might get you where you want to go. >> It's just maturing now but I found his blog posts illuminating. > > I'll be do

Re: Problems with clojure couchdb

2010-10-12 Thread Moritz Ulrich
I would also recommend using batch-write for this. It's *much* faster. Regarding your error: Maybe you open too many sockets which don't get closed and your process runs out of file descriptors. On Tue, Oct 12, 2010 at 7:13 AM, David Nolen wrote: > On Tue, Oct 12, 2010 at 12:45 AM, Mark Engelber

Re: New Release of the Clojure Debugging Toolkit

2010-10-12 Thread leo
This works for me under Windows 7. I set all forward slashes paths in my .emacs file like this: (progn (setq cdt-dir "c:/msysgit/cdt") (setq cdt-source-path "c:/clj/clojure-1.2.0/src/jvm;c:/clj/ clojure-1.2.0/src/clj;c:/clj/clojure-contrib-1.2.0/src/main/clojure/ clojure/contrib;") (load-fil

Clojars SSH key change?

2010-10-12 Thread Saul Hazledine
Hello, I just got the following error back from ssh/scp when copying something back to clojars.org: @@@ @ WARNING: POSSIBLE DNS SPOOFING DETECTED! @ @@@ The RSA host key

Leiningen hangs after finished tasks

2010-10-12 Thread Benjamin Teuber
Hi, I'm recently having problems where leiningen hangs for like 20 secondes after everything is done (I've added print statements to a custom task, so I'm pretty sure nothing has to be done anymore). I'm using Mac OS Snow Leopard, but a friend of mine is experiencing the same with Ubuntu. Did any

Re: Screencast of the Emacs front end to the Clojure Debugging Toolkit:

2010-10-12 Thread Walter van der Laan
You were right, it was a classpath problem. But since I'm new to classpaths it took me some time to get it right. Thanks again, emacs+cdt makes development a lot easier :D And, in case anyone needs to solve the same problems, these are the steps to get cdt running for a leiningen-based project:

help with a sexp to function macro ...

2010-10-12 Thread Sunil S Nandihalli
Hello everybody, I would like some help in writing a macro which accepts the return value from mathematica and create a function in clojure which can be called. I am kind of inexperienced writing macros.. I will try to describe what I have done (does not work ) and request you all to help me modif

Re: Find reference type on classpath

2010-10-12 Thread Michael Wood
On 11 October 2010 22:39, Phil Hagelberg wrote: > On Mon, Oct 11, 2010 at 12:21 PM, Ivan Willig wrote: >> I often run into this issue where I am follow a Java documentation where >> they developers fail to explain where they import packages from.  In most >> Java IDE's you can search your classpa