using custom zippers from clojure.zip

2011-08-26 Thread Sunil S Nandihalli
Hello everybody, I am trying to figure out how to use the zippers. And I wrote the following code https://gist.github.com/1172883 It seems to get in-to an infinite loop ..can somebody help me figure it out. The purpose of the last s-expression is to simply return a new s where all the values

Re: using custom zippers from clojure.zip

2011-08-26 Thread Sunil S Nandihalli
as it always happens.. I figured the problem as soon as I posted it . I just had to replace the branch? function from (constantly true) with identity . The problem was it was treating even nil values as valid nodes and hence getting into an infinite loop. Sorry for this. Thanks again, Sunil. On

uberjar starts a repl

2011-08-26 Thread finbeu
Hello, I have an application written that gets deployed using a uberjar built with leiningen. Works perfectly fine. For training purposes, I want to give a training version of that application that does not start the application (the -main routine) but a REPL so users can interactively use

Re: JVM 7 support (invokedynamic)

2011-08-26 Thread Paul Stadig
On Thu, Aug 25, 2011 at 5:41 PM, Tal Liron tal.li...@gmail.com wrote: So, after setting up a JVM 7 environment to play with Clojure, and enthusiastically rummaging through the codebase, I have good news and bad news. :) So, when Clojure calls a function, it either already has the instance in

Re: JVM 7 support (invokedynamic)

2011-08-26 Thread Paul Stadig
On Thu, Aug 25, 2011 at 6:05 PM, Tal Liron tal.li...@gmail.com wrote: Hmm... If you didn't have to worry about Java 7 compatibility, for one thing with invokedynamic you could remove a lot of code from Clojure. No more IFn or AFn. You simply have a method handle. Actually, Clojure's

Re: I/O

2011-08-26 Thread Lee Spector
On Aug 25, 2011, at 11:39 PM, Dave Ray wrote: user.dir is the directory from which the JVM was launched, i.e. the initial working directory of the process. So, you're probably double-clicking the Clooj jar which resides in your Downloads folder and thus all further file system operations

Re: Lein uberjar hangs when swank is required in the namespace.

2011-08-26 Thread Rob Wolfe
On 25 Sie, 23:10, Lars Rune Nøstdal larsnost...@gmail.com wrote: It's hanging here too, but I have no idea why; I'm not including swank. Is there any verbose mode for lein? Maybe there is some problem with network (firewall or something) and you can not get jars from remote repository. Does

Re: I/O

2011-08-26 Thread Terje Dahl
I disagree. Simply use: (System/getProperty user.home) This will give you a useful path to work with, no matter where you start from. Works on my Mac. Should work on Windows. From there I would build a simple library which tests which OS I am on, and gives me the paths to the conventional

Re: I/O

2011-08-26 Thread Lee Spector
On Aug 26, 2011, at 9:15 AM, Terje Dahl wrote: I disagree. Simply use: (System/getProperty user.home) This will give you a useful path to work with, no matter where you start from. Works on my Mac. Should work on Windows. From there I would build a simple library which tests which

Re: Peculiar transients behaviour

2011-08-26 Thread Aaron Bedra
Adding the additional zero did trigger the issue for me. I have bumped the ticket into Release.Next. Thanks for the clarification. Cheers, Aaron Bedra -- Clojure/core http://clojure.com On 08/25/2011 01:21 PM, Alan Malloy wrote: Update: just built master, and issue still exists. If you

Notation conventions

2011-08-26 Thread Terje Dahl
I find myself making alot of mistakes when dealing with atoms. I usually remember the datatype and/or structure returned by a function, or held in a binding or symbol - but not wether it is an atom or not. Any naming-conventions for atoms, such as ending with ? for predicate, or ! for sideeffect?

Re: Notation conventions

2011-08-26 Thread Fogus
I guess the first question is; why so many atoms? But regardless, there is no standard for naming such things. If you know you're dealing with atoms only (as opposed to a reference in general) then something like `foo-atom` would suffice I'd say. -- You received this message because you are

StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Tassilo Horn
Hi all, I'm toying around with the lazy, tail-recursive quick-sort implementation Michael Fogus and Chris Houser present in their book The Joy of Clojure: --8---cut here---start-8--- (in-ns 'user) (defn sort-parts Lazy, tail-recursive, incremental

Re: I/O

2011-08-26 Thread cej38
Friends, Thank you for the replies. I think you have proved my point. -- 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: about the lazy-seq

2011-08-26 Thread 机械唯物主义 : linjunhalida
you mean this? http://clojure.org/lazy maybe this can be helpful: http://en.wikipedia.org/wiki/Lazy_evaluation On Wed, Aug 24, 2011 at 1:48 PM, xiaoguizi87 xiaogui...@gmail.com wrote: I feel it is too difficult to understand the 'lazy-seq'.Can someone recommend something may help me? I have

problems with gen-class :exposes-methods

2011-08-26 Thread Oliver
Hello. This is with Clojure 1.2. This works: (gen-class :namecom.nsn.isar.saxon.ext_funcs.ClojureReceiver :extends net.sf.saxon.event.ProxyReceiver :exposes {nextReceiver { :get getReceiver :set setReceiver } } :exposes-methods { startDocument superStartDocument,

Re: Compojure

2011-08-26 Thread Jaskirat Singh Veen
You might want to check out this excellent article by Andrew Brehaut that covers a typical web stack in clojure with many examples - http://brehaut.net/blog/2011/ring_introduction Jaskirat On Wed, Aug 24, 2011 at 6:43 PM, Michael Jaaka michael.ja...@googlemail.com wrote: RESTFUL in Clojure?

Re: Why can't I print new sequence?

2011-08-26 Thread Avram Aelony
Any reason not to use a Set ? On Wed, Aug 24, 2011 at 3:57 PM, Ken Wesson kwess...@gmail.com wrote: On Wed, Aug 24, 2011 at 5:58 PM, octopusgrabbus octopusgrab...@gmail.com wrote: (defn f1     [in-seq]     (loop [new-seq [] cur-seq in-seq]     (if (nil? (first cur-seq))    

Re: JVM 7 support (invokedynamic)

2011-08-26 Thread Kevin Ilchmann Jørgensen
This means I can read the rest of the logs http://clojure-log.n01se.net/date/2008-09-03.html and it stills hold up ? i.e we want tagged numbers ? /Kevin On Thu, Aug 25, 2011 at 2:51 PM, Aaron Bedra aaron.be...@gmail.com wrote: That's correct.  That is why Clojure/core hasn't prioritized this

weird behavior: what is the difference between sequential? and my own predicate?

2011-08-26 Thread Shouxun Yang
Dear Clojurians, while playing with http://4clojure.com I found a perplexing behavior when I submit my own code for implementing my own poor implementation of my-flatten for problem 28: (defn my-flatten [coll] (loop [acc [] coll coll] (if-let [[a coll] coll] (if (or (list? a)

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Paul Mooser
Looking at the stack trace, I suspect this is the old problem of layering too many filters on top of the same seq. If I understand the issue correctly, when you have enough layers of filter on top of a seq, when you finally try to access elements, as it evaluates each layer, it is going to be

Re: JVM 7 support (invokedynamic)

2011-08-26 Thread David Nolen
On Thu, Aug 25, 2011 at 9:05 AM, Kevin Ilchmann Jørgensen kijm...@gmail.com wrote: This means I can read the rest of the logs http://clojure-log.n01se.net/date/2008-09-03.html and it stills hold up ? i.e we want tagged numbers ? /Kevin 1.3 went a different route. Fast path for 64bit

Re: weird behavior: what is the difference between sequential? and my own predicate?

2011-08-26 Thread Michael Wood
Hi On 25 August 2011 18:16, Shouxun Yang yang.shou...@gmail.com wrote: Dear Clojurians, while playing with http://4clojure.com I found a perplexing behavior when I submit my own code for implementing my own poor implementation of my-flatten for problem 28: (defn my-flatten  [coll]  (loop

Re: weird behavior: what is the difference between sequential? and my own predicate?

2011-08-26 Thread Tassilo Horn
Shouxun Yang yang.shou...@gmail.com writes: (defn my-flatten [coll] (loop [acc [] coll coll] (if-let [[a coll] coll] (if (or (list? a) (vector? a)) (recur acc (if (empty? coll) (vec a) (conj (vec a) coll)))

Re: weird behavior: what is the difference between sequential? and my own predicate?

2011-08-26 Thread Shouxun Yang
Michael, thank you very much. I never paid much attention to the chunked seq feature before. The effect is surprising to my Common Lisp / OCaml background. I thought my code good enough to cover the test cases. Always new thing to learn. shouxun 在 2011-8-26 下午11:42,Michael Wood

Re: weird behavior: what is the difference between sequential? and my own predicate?

2011-08-26 Thread Michael Wood
Hi On 26 August 2011 17:44, Tassilo Horn tass...@member.fsf.org wrote: [...] BTW2: Instead of (empty? coll), use the idiomatic (seq coll) recipe. You have that one backwards :) user= (doc empty?) - clojure.core/empty? ([coll]) Returns true if coll has no items - same

Re: I/O

2011-08-26 Thread Laurent PETIT
2011/8/26 Lee Spector lspec...@hampshire.edu On Aug 25, 2011, at 9:27 PM, Ken Wesson wrote: On Thu, Aug 25, 2011 at 6:49 PM, Lee Spector lspec...@hampshire.edu wrote: While slurp and spit are beautifully elegant it's not so elegant to tell slurp how to find the file you want it to slurp.

Re: weird behavior: what is the difference between sequential? and my own predicate?

2011-08-26 Thread Shouxun Yang
在 2011-8-26 下午11:44,Tassilo Horn tass...@member.fsf.org写道: Shouxun Yang yang.shou...@gmail.com writes: (defn my-flatten [coll] (loop [acc [] coll coll] (if-let [[a coll] coll] (if (or (list? a) (vector? a)) (recur acc (if (empty? coll)

Re: I/O

2011-08-26 Thread Lee Spector
On Aug 26, 2011, at 12:01 PM, Laurent PETIT wrote: What kind of problem with Eclipse / CCW ? CCW uses a standard java launcher, so to say it uses the Eclipse Java Development Tools defaults, which are to create a launch configuration with the project's path as the current directory (of

Re: weird behavior: what is the difference between sequential? and my own predicate?

2011-08-26 Thread Tassilo Horn
Michael Wood esiot...@gmail.com writes: BTW2: Instead of (empty? coll), use the idiomatic (seq coll) recipe. You have that one backwards :) Ah, that must be the reason my apps don't ever work! ;-) So BTW3: Use (seq coll) and swich the then/else parts of the if. Bye, Tassilo -- You

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Tassilo Horn
Paul Mooser taron...@gmail.com writes: Hi Paul, Looking at the stack trace, I suspect this is the old problem of layering too many filters on top of the same seq. If I understand the issue correctly, when you have enough layers of filter on top of a seq, when you finally try to access

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Tassilo Horn
Tassilo Horn tass...@member.fsf.org writes: I've seen people solve these issues by forcing the intermediate seqs, but that doesn't work well for a lazy situation such as this. Indeed, putting a doall around the filter and remove seems to prevent the stack overflow. A better solution seems

Re: I/O

2011-08-26 Thread Marek Kubica
On Thu, 25 Aug 2011 19:24:13 +0300 Mats Rauhala mats.rauh...@gmail.com wrote: The simplest way is to slurp or spit. slurp reads a file into a string, and spit writes a string into a file. Yes, true, but first you have to know them. And slurp is not the first think I am looking for when

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Paul Mooser
If you search for filter and StackOverflowError in this group, you will find people discussing related issues. On Aug 26, 10:30 am, Tassilo Horn tass...@member.fsf.org wrote: Do you have a link to the issue?  I've tried searching for filter or layer at dev.clojure.org, but I can't find

Joy of Clojure lazy quicksort doesn't seem to save comparisons?! (was: StackOverflowError with lazy qsort of The Joy of Clojure)

2011-08-26 Thread Tassilo Horn
Tassilo Horn tass...@member.fsf.org writes: Now I'm really a bit confused. I've just added atom counters and increased them in the comparison functions in order to check if the lazy variants really test less than the standard sort. A better solution [that doesn't overrun the stack] seems to be

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Tassilo Horn
Paul Mooser taron...@gmail.com writes: Hi Paul, If you search for filter and StackOverflowError in this group, you will find people discussing related issues. Thanks, I've found some explanation by Meikel Brandmeier who explains the layering issue. But do we really have to live with that?

Re: StackOverflowError with lazy qsort of The Joy of Clojure

2011-08-26 Thread Alan Malloy
On Aug 26, 12:40 pm, Tassilo Horn tass...@member.fsf.org wrote: Paul  Mooser taron...@gmail.com writes: Hi Paul, If you search for filter and StackOverflowError in this group, you will find people discussing related issues. Thanks, I've found some explanation by Meikel Brandmeier who

Re: uberjar starts a repl

2011-08-26 Thread Phil Hagelberg
On Fri, Aug 26, 2011 at 1:15 AM, finbeu info_pe...@t-online.de wrote: How can I build such a uberjar that starts a repl instead of -main? The REPL should have also some nice editing features (I think I have to add jLine or how is it called?) For a raw repl you should be able to do: $ lein

Re: Notation conventions

2011-08-26 Thread Terje Dahl
OK. Thanks. Regarding why so many atoms: I have rewritten a GUI-based (Swing) app to Clojure (our company's product: A Java applet), and where I previously typically had extended JPanels, adding variables and methods to them, I have (for now) replaced them with maps in atoms, where the maps

Please optimize this with macro (grep and context result grabing)

2011-08-26 Thread Michael Jaaka
Hi! I have got (def *g) (def *g1) (def *g2) (def *g3) (def *g4) (def *g5) (def *g6) (defmacro grep[ pat in body ] `(do (when-let[ r# (re-matches (re-pattern ~pat) ~in) ] (binding [ *g (first r#) *g1 (get r# 1) *g2 (get r# 2) *g3 (get r# 3)

is there a 4Clojure forum anywhere?

2011-08-26 Thread chepprey
I've just started going through the problems on http://4clojure.com . Very fun. Does anyone know if there's a discussion forum dedicated to that site? I've searched but nothing jumps out. I'm looking for a hint on how to solve the Nth Element problem (without cheating and using the nth

Re: JVM 7 support (invokedynamic)

2011-08-26 Thread Charles Nutter
This is the best summary of how Clojure *could* benefit from invokedynamic. Clojure doesn't dispatch as dynamically as JRuby, but there is a dynamic component...specifically, you have to go get the fn. That repeated get would disappear with invokedynamic, In fact, anywhere you're going after

Re: is there a 4Clojure forum anywhere?

2011-08-26 Thread Bob Shock
Is there a recovery group for 4clojure.com addicts? Stop now! Don't go further before it's too late and you are checking the website every five minutes waiting for the next problem, obsessing over every character in your code so you can get one of the best code golf scores, etc. But seriously,

Re: Please optimize this with macro (grep and context result grabing)

2011-08-26 Thread gaz jones
do you know about the re-groups function, or are you just doing this for an exercise? On Fri, Aug 26, 2011 at 6:57 PM, Michael Jaaka michael.ja...@googlemail.com wrote: Hi! I have got (def *g) (def *g1) (def *g2) (def *g3) (def *g4) (def *g5) (def *g6) (defmacro grep[ pat in body ]

Re: Please optimize this with macro (grep and context result grabing)

2011-08-26 Thread Michael Jaaka
Well I think that this is a different case. On 27 Sie, 03:15, gaz jones gareth.e.jo...@gmail.com wrote: do you know about the re-groups function, or are you just doing this for an exercise? On Fri, Aug 26, 2011 at 6:57 PM, Michael Jaaka michael.ja...@googlemail.com wrote: Hi! I

Re: is there a 4Clojure forum anywhere?

2011-08-26 Thread Alan Malloy
I haven't heard of one either, and I'm maintainer and co-founder of 4clojure. If someone (that means you!) starts such a forum, I'm happy to link to it from 4clojure proper. On Aug 26, 5:59 pm, Bob Shock shock...@gmail.com wrote: Is there a recovery group for 4clojure.com addicts? Stop now!

Re: mini-version of clojure.jar?

2011-08-26 Thread Chas Emerick
You might want to give Pack200 a try; it's a Java classfile-aware compression algorithm that can produce jars that are far more compact than e.g. if you were to only gzip applet jars on their way out to your users. Lots of info about it if you feel like googling. Using a build from the