Re: a macro

2010-10-13 Thread Meikel Brandmeyer
Hi, On 13 Okt., 08:56, Laurent PETIT wrote: > So in short: calling eval from the macro, on its argument. Beware the leopard! user=> (defn f [constant] `(+ x# (* ~constant y#))) #'user/f user=> (defn variables* [form] (if (seq? form) (reduce into [

Re: a macro

2010-10-13 Thread Sunil S Nandihalli
basically the following is the macro that creates a function from the expression calculated using mathematica.. it seems to be doing something still not the whole thing.. hopefully some of you may be able to help me. (defmacro sexp2fn [sexp] (let [sym (eval sexp) vars (eval (math (Varia

Re: a macro

2010-10-13 Thread Meikel Brandmeyer
Hi, On 13 Okt., 11:19, Sunil S Nandihalli wrote: > (defmacro sexp2fn [sexp] >   (let [sym (eval sexp) >         vars (eval (math (Variables sexp)))] >     (println [sym vars]) >     `(fn ~vars >         ~sym))) Try the following: (defn evaled-variables [form] (eval `(math (Variables ~form)

Re: Problems with clojure couchdb

2010-10-13 Thread Moritz Ulrich
On Wed, Oct 13, 2010 at 4:00 AM, Mark Engelberg wrote: > 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

Re: Creating a new library

2010-10-13 Thread lprefontaine
Good to know... is this written somewhere ? I looked at Clojars yesterday but did not find anything... Luc P. Saul Hazledine wrote .. > 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 ot

Re: Help to optimize palindrome search from input file

2010-10-13 Thread Stephen C. Gilardi
On Oct 12, 2010, at 3:02 PM, tonyl wrote: > (defn palindrome? [s] > (= s (reduce str (reverse s One opportunity to micro-optimize is to replace "reduce str" with "apply str". str uses a StringBuilder object to build a string from its arguments. When you use reduce, the code walks down s a

Re: Creating a new library

2010-10-13 Thread Saul Hazledine
On Oct 13, 1:21 pm, lprefonta...@softaddicts.ca wrote: > Good to know... is this written somewhere ? I looked at Clojars yesterday > but did not find anything... > Its mentioned near the end of the tutorial: http://github.com/ato/clojars-web/wiki/tutorial Saul -- You received this message bec

Re: Creating a new library

2010-10-13 Thread Meikel Brandmeyer
Hi, On 13 Okt., 07:59, Saul Hazledine wrote: > As I understand it, its fine to put jars from other projects on > Clojars. If you do this, it is recommended to use your own groupid or > org.clojars. as the groupid. That way people know that > the jar files aren't from the originating team. If the

Re: New Release of the Clojure Debugging Toolkit

2010-10-13 Thread atreyu
I suppose it could be a way to unify both versions using (System/ getProperty "path.separator") and (System/getProperty "file.separator") I try to fix it like Leo but i get a regexp exception using (reval) with \ -- You received this message because you are subscribed to the Google Groups "Clojur

Re: Creating a new library

2010-10-13 Thread lprefontaine
I need a new pair of eyes... Saul Hazledine wrote .. > On Oct 13, 1:21 pm, lprefonta...@softaddicts.ca wrote: > > Good to know... is this written somewhere ? I looked at Clojars yesterday > > but did not find anything... > > > > Its mentioned near the end of the tutorial: > http://github.com/a

Re: New Release of the Clojure Debugging Toolkit

2010-10-13 Thread atreyu
I suppose it could be a way to unify both versions using (System/ getProperty "path.separator") and (System/getProperty "file.separator") I add the leo changes (to master vesion -lesses changes-) and it works for me thanks!! On Oct 12, 2:53 pm, leo wrote: > This works for me under Windows 7. I se

Override print-method of struct

2010-10-13 Thread andrei
How can I override print-method for a map, defined with defstruct? I have to create object hierarchy: one map is a parent for another, i.e. it holds link to a child, and another is a child for the first one, i.e. holds link to a parent. When I try to print it, I get StackOverflowError since printe

Re: precise numbers

2010-10-13 Thread Nicolas Oury
On Tue, Oct 12, 2010 at 8: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. > > The only way to do so is to have numbers with infinite precision. For example as lazy-seq of their digits. But: - it i

Re: strange bug in range or lazy-seq?

2010-10-13 Thread Stuart Halloway
After thinking about it some more, I don't understand it either. I have created a ticket for this: https://www.assembla.com/spaces/clojure/tickets/457-lazy-recursive-definition-giving-incorrect-results. As a workaround, eliminate the lazy intermediary "nums" sequence, e.g. (def primes (concat

Re: precise numbers

2010-10-13 Thread Felix H. Dahlke
Nice rant, I learned something here :) I somehow thought BigDecimal wouldn't have any precision issues, but I probably never noticed because I can only think in base-10 arithmetic. Has been good enough for my humble precision problems so far though, never had a notable performance issue with it eit

Seen in #clojure – October 7th w/ maybe-m monad

2010-10-13 Thread Jacek Laskowski
Hi, I was reading the blog entry Seen in #clojure – October 7th [1] and couldn't stop thinking it might be easier with monads. Since I'm new to monads, Clojure and functional programming in general I'd appreciate any comments on my solution, esp. with regards to maybe-m monad's use. I guess there

Re: precise numbers

2010-10-13 Thread David Sletten
On Oct 12, 2010, at 5:44 PM, Brian Hurt wrote: > For example, in base 10, 1/3 * 3 = 0.9... It may seem counterintuitive, but that statement is perfectly true. 1 = 0.... That's a good test of how well you understand infinity. Of course, the problem arises when we truncate the string

Re: Test-driven development in Clojure

2010-10-13 Thread Felix H. Dahlke
I see. So instead of using interfaces and implementations of these, I would simply use closures, one for mock and one for production? That was actually my first attempt, but I didn't like it back then. Take this code for example - passing a function just to have it called feels weird: (defn load-

Re: precise numbers

2010-10-13 Thread Jarl Haggerty
A slight tangent, is there anyway to represent exact square roots? I'd like to have an exact closed form fibonacci function. On Oct 13, 1:28 pm, David Sletten wrote: > On Oct 12, 2010, at 5:44 PM, Brian Hurt wrote: > > >   For example, in base 10, 1/3 * 3 = 0.9...   > > It may seem counterint

Re: precise numbers

2010-10-13 Thread Alan
Um, not if you're going to try and turn them into numbers first. But if you store them as ['sqrt 5] or some similar operator/operand pair, then you can manipulate them symbolically and wait for them to cancel out, instead of evaluating them. This requires implementing some kind of symbolic-algebra

Re: Override print-method of struct

2010-10-13 Thread Laurent PETIT
You can add a :type metadata to your maps, and this can be catched by the (type) method of multimethods. But if you have parent -> child -> parent -> child ... relationships, I guess that you're building a tree made of mixins of maps and refs to maps ... and indeed this should bell some rings in y

Re: Creating a new library

2010-10-13 Thread Vilson Vieira
Thank you guys about all the valuable answers. I've pushed the jars to Clojars on my group [1] and updated the wiki with a simple tutorial on how to create a POM to non-clojure jars [2]. All the best. [1] http://clojars.org/groups/org.clojars.automata [2] http://github.com/ato/clojars-web/wiki/P

Re: Is ClojureCLR converging toward a release?

2010-10-13 Thread eyeris
Thank you for all the work you've put into this! On Oct 11, 5:39 pm, dmiller wrote: > Check out the downloads area onhttp://github.com/richhickey/clojure-clr. > Grabclojure-clr-1.2.0.zip.  Unzip, start up Clojure.Main.exe and you > should be running.  The zip also contains Clojure.Compile.exe, w

Re: precise numbers

2010-10-13 Thread Felix H. Dahlke
On 13/10/10 22:28, David Sletten wrote: > > On Oct 12, 2010, at 5:44 PM, Brian Hurt wrote: > >> For example, in base 10, 1/3 * 3 = 0.9... > > It may seem counterintuitive, but that statement is perfectly true. > 1 = 0.... > > That's a good test of how well you understand infinity.

Re: precise numbers

2010-10-13 Thread Matt Fowles
Felix~ You are correct that the sequence of numbers 0.9 0.99 0.999 ... asymptotically approaches 1; however, the number 0.... (with an infinite number of 9s) is equal to 1. The formal proof of this is fairly tricky as the definition of the real number is usually done as an equivalence class

Re: precise numbers

2010-10-13 Thread David Sletten
Here's a slightly more informal argument. Suppose you challenge me that 1 is not equal to 0.... What you are saying is that 1 - 0.... is not equal to 0, i.e., the difference is more than 0. But for any positive value arbitrarily close to 0 I can show that 0.999... is closer to 1 than tha

Re: precise numbers

2010-10-13 Thread Mike Meyer
On Thu, 14 Oct 2010 00:27:39 +0200 "Felix H. Dahlke" wrote: > On 13/10/10 22:28, David Sletten wrote: > > > > On Oct 12, 2010, at 5:44 PM, Brian Hurt wrote: > > > >> For example, in base 10, 1/3 * 3 = 0.9... > > > > It may seem counterintuitive, but that statement is perfectly true. >

Re: precise numbers

2010-10-13 Thread Terrance Davis
The quick and dirty proof (not formal proof) for 1 = .... 1/3 = .33... 2/3 = .66... 3/3 = .99... Think of 3/3 as 1/3 (that is .3...) times 3. -Terrance Davis www.terrancedavis.com Felix H. Dahlke wrote: On 13/10/10 22:28, David Sletten wrote: On Oct 12, 2010, at 5:44

Re: Override print-method of struct

2010-10-13 Thread andrei
That works, thanks! Yeah, I understand that it is not the best data structure to use. The task is to create a tree, and it is needed to get all children and all parents of specified node in this tree in a constant time. So, I cannot see another way to do it except storing refs both from parents t

Re: Override print-method of struct

2010-10-13 Thread meb
Instead of using a ref, you might consider using a closure, which seems a little more functional. So every child would simply store a function that when called would return the map of the parent, map you capture using a closure. This would also reduce your printing problems because functions just

Re: Help to optimize palindrome search from input file

2010-10-13 Thread Btsai
I think the indexing in all-combs may be off, causing it to miss certain combinations/substrings. user=> (all-combs "abc") ("a" "ab") I used this instead: (defn substrings [s] (let [length (count s)] (for [i (range length) j (range (inc i) (inc length))] (subs s i j us

Re: Test-driven development in Clojure

2010-10-13 Thread Armando Blancas
One thing that OOP and FP can have in common is the use of polymorphism. With protocols and types you can implement your Java design efficiently because you'll get basically the same interfaces and classes. The thing about hiding the calls to instances of a data type is only to make the client code

Re: Is ClojureCLR converging toward a release?

2010-10-13 Thread Miki
What's the status on Mono? On Oct 11, 3:39 pm, dmiller wrote: > Check out the downloads area onhttp://github.com/richhickey/clojure-clr. > Grab clojure-clr-1.2.0.zip.  Unzip, start up Clojure.Main.exe and you > should be running.  The zip also contains Clojure.Compile.exe, which > you can invoke

Re: precise numbers

2010-10-13 Thread Felix H. Dahlke
OKay, I think I get it. Thanks :) On 14/10/10 00:56, David Sletten wrote: > Here's a slightly more informal argument. Suppose you challenge me that > 1 is not equal to 0.... What you are saying is that 1 - 0.... is > not equal to 0, i.e., the difference is more than 0. But for any > positi