Re: Stumped - Java hangs when using Swing in Slime

2009-02-12 Thread David
Here's my experience with 1.6.0_12: When I run (load-file "celsius.clj") (celsius/celsius) from a REPL in a Cygwin rxvt, the problem recurs as before: The Swing window comes up, but input is not echoed in the swing window until I hit return in the rxvt window. If I use a cmd shell, I do

Re: Generic functions: things, models, and protocols revisited

2009-02-12 Thread David Nolen
> > > > Seems like this kind of dispatch and the Datalog project might meet up > soon? > > Or am I totally wrong? > > I have given it zero thought. Perhaps interesting to pursue? Rich had brought it up in conversations about predicate dispatch. Could greatly help from the performance side of thin

Re: Generic functions: things, models, and protocols revisited

2009-02-12 Thread mikel
On Feb 12, 1:27 pm, David Nolen wrote: > Neat! You've removed the need to even define a dispatch-fn. Maybe; maybe not. The built-in dispatch mechanism uses a selection scheme that applies a sequence of increasingly restrictive, but also increasingly costly, tests; basically, the tests in order

Re: How to tell if a variable is bound

2009-02-12 Thread Chouser
On Thu, Feb 12, 2009 at 7:10 PM, Conrad wrote: > > Hi, is there a standard way to tell if a variable is bound? I couldn't > find a way. > Basically I want something like this, but without the horrible hacks: > >> (def foo 33) That's actually doing two different steps: 1. creating a Var named 'fo

Re: Reading... from a reader

2009-02-12 Thread Phil Hagelberg
"Stephen C. Gilardi" writes: > Now I apply the patch and use the convenience it offers: > > user=> (def a (java.io.StringReader. "123[145]")) > #'user/a > user=> (read a) > 123 > user=> (read a) > 145 > > The "[" on the input stream was lost so the second obje

Re: bug + patch: lazy branch take-while is broken

2009-02-12 Thread Chouser
On Thu, Feb 12, 2009 at 10:20 PM, Chouser wrote: > There's a misplaced paren in take-while in the lazy branch. Patch attached. For what it's worth, using the lazy branch for my clojure-classes project, I had to make two kinds of changes (not counting the patch to core). I had to remove a coupl

Re: Lazy graph walk

2009-02-12 Thread Jason Wolfe
I'm not sure if I fully understand what you want, but I find this sort of thing is often cleanest using mutable data structures, i.e., (off the top of my head, possibly buggy), (defn visit ([node] (visit node (HashSet.))) ([node s] (when-not (.contains s node)

Re: java.io.IOException: Not enough storage is available to process this command

2009-02-12 Thread kkw
I've copied-and-pasted (not typed in) the following code into the REPL: (str "INSERT ALL" " INTO mdroverffprd.mc_system_user_region (system_user_id, region_code) VALUES ('" 'a "', 'RS01')" " INTO mdroverffprd.mc_system_user_region (system_user_id, region_code) VALUES ('" 'a "', 'RS02')"

Re: Lazy graph walk

2009-02-12 Thread Jeffrey Straszheim
Sounds good. The one hitch is that I'm passing around a "visited" hash (I'm actually traversing a graph looking for spanning trees), so I end up calling (reduce XX [visited acc] (get-children node)) on the children, which (I think) kills the laziness. On Thu, Feb 12, 2009 at 10:18 PM, Jason Wolfe

Re: generated class with overloaded methods

2009-02-12 Thread Stuart Sierra
On Feb 12, 6:12 pm, Laurent PETIT wrote: > Do you know if there's a way to overload methods with the same arity, then ? > > I'm thinking about .read(char ) .read(byte ) .read(String ) .read(Integer ) > ... for example,  ? I think they're all the same method, from the Clojure point of view. If yo

bug + patch: lazy branch take-while is broken

2009-02-12 Thread Chouser
There's a misplaced paren in take-while in the lazy branch. Patch attached. --Chouser --~--~-~--~~~---~--~~ 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 To

Re: Lazy graph walk

2009-02-12 Thread Jason Wolfe
On Feb 12, 4:01 pm, Jeffrey Straszheim wrote: > It is easy to do a lazy preorder walk of a tree (in psuedo-clojure): > > (fn visit [node] >   (lazy-cons node (map visit (get-children node > > So, that much is obvious.  However, I cannot think of an obvious way to do a > post-order traversal

Re: Random elements

2009-02-12 Thread Jason Wolfe
On Feb 11, 4:06 pm, Phil Hagelberg wrote: > I think that the bike shed should definitely be red. I hadn't heard that one before :) Issue here: http://code.google.com/p/clojure-contrib/issues/detail?id=29 -Jason --~--~-~--~~~---~--~~ You received this message b

Minor documentation fix needed for "drop-last"

2009-02-12 Thread AlamedaMike
At http://clojure.org/api#drop-last, the formal parameter "s" needs to be changed to "coll": (drop-last s) (drop-last n s) Return a lazy seq of all but the last n (default 1) items in coll --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread Timothy Pratley
That's very neat Perry! user=> (let-> [? 5] inc) 6 user=> (let-> [? 5] inc (+ 2 ?)) 8 user=> (let-> [? 5] inc (+ 2 ?) (+ ? 3)) 11 user=> (let-> [? 5] inc (+ 2 ?) (+ ? 3) (+ 4)) 4 What should happen when/if the seq arg doesn't contain the symbol? I believe how you currently handle it is correct a

Re: Naming Conventions for Functions that Modify State

2009-02-12 Thread Jeffrey Straszheim
Well, there is the IO! macro to wrap side effects. This works with the transactions mechanism. So foo! does show up, but is not followed rigorously. On Thu, Feb 12, 2009 at 7:57 PM, Kevin Albrecht wrote: > > If no one knows of any existing conventions, does anyone have ideas > for conventions?

Re: Naming Conventions for Functions that Modify State

2009-02-12 Thread Kevin Albrecht
If no one knows of any existing conventions, does anyone have ideas for conventions? --~--~-~--~~~---~--~~ 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 To un

Re: How to tell if a variable is bound

2009-02-12 Thread James Reeves
On Feb 13, 12:10 am, Conrad wrote: > Hi, is there a standard way to tell if a variable is bound? I couldn't > find a way. There's an isBound method on the Var class: (.isBound #'foo) But the var has still got to exist, i.e. you have to (declare foo) first. If you want to check a var _exists_,

Re: How to tell if a variable is bound

2009-02-12 Thread Laurent PETIT
There's certainly better, but at least, you can try this : (def void) (.isBound (var void)) ; or (.hasRoot (var void)) depending on what you want -- Laurent 2009/2/13 Conrad > > Hi, is there a standard way to tell if a variable is bound? I couldn't > find a way. > Basically I want something

Re: How to tell if a variable is bound

2009-02-12 Thread Jeffrey Straszheim
Try: (contains? (ns-map *ns*) 'foo) *ns* binds to the current namespace. On Thu, Feb 12, 2009 at 7:10 PM, Conrad wrote: > > Hi, is there a standard way to tell if a variable is bound? I couldn't > find a way. > Basically I want something like this, but without the horrible hacks: > > (defn bou

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread Perry Trolard
Sorry to keep revising things; here's an improved version of let->, which better supports (as near as I can tell -- please try to break) arbitrary let-style destructuring. (The previous version favored single-symbol bindings, but I can imagine use cases where [a b :as all] kinds of destructuring a

How to tell if a variable is bound

2009-02-12 Thread Conrad
Hi, is there a standard way to tell if a variable is bound? I couldn't find a way. Basically I want something like this, but without the horrible hacks: (defn bound? [var] (try (eval var) true (catch java.lang.Exception x false))) > (bound? 'foo) false > (def foo 33) 33

Lazy graph walk

2009-02-12 Thread Jeffrey Straszheim
It is easy to do a lazy preorder walk of a tree (in psuedo-clojure): (fn visit [node] (lazy-cons node (map visit (get-children node So, that much is obvious. However, I cannot think of an obvious way to do a post-order traversal lazily. I sort of assume it cannot be done, as the whole po

Re: Got a Clojure library?

2009-02-12 Thread Jeffrey Straszheim
Sure. I'll send the document tomorrow. On Thu, Feb 12, 2009 at 7:48 AM, Rich Hickey wrote: > > > > On Feb 11, 10:34 pm, Jeffrey Straszheim > wrote: > > I'd love to add Clojure-Datalog. I'm still working on it, but it now > > implements complete Datalog rules, including stratified negation and

Re: Is it possible to have Eclipse build an executable .jar with Clojure-dev

2009-02-12 Thread Laurent PETIT
Hello again, As I said in my first answer, clojuredev doesn't provide anything more than what Eclipse has to offer in this area, at least not yet. And honestly, I don't know if eclipse provides such a functionality "out of the box". Cheers, -- Laurent 2009/2/11 Rayne > > Do you mean, just e

Re: How to build tree with nodes that 'point' to each other?

2009-02-12 Thread Jeffrey Straszheim
My Datalog stuff has a lot of circularities, and I chose the "map of keys" approach. It has worked pretty well for me. On Thu, Feb 12, 2009 at 3:24 PM, Jason Wolfe wrote: > > I think there are two basic ways to do this. One is to use one of the > mutable Clojure types mentioned above (or any m

Re: generated class with overloaded methods

2009-02-12 Thread Laurent PETIT
Hello, Thanks for having shared that, Do you know if there's a way to overload methods with the same arity, then ? I'm thinking about .read(char ) .read(byte ) .read(String ) .read(Integer ) ... for example, ? -- Laurent 2009/2/12 Craig McDaniel > > For the benefit of others, since this t

Re: A stupid beginners question about Compile

2009-02-12 Thread Stephen C. Gilardi
On Feb 12, 2009, at 4:56 PM, anderspe wrote: I have tried to compile a simple "Hello World" but the closest a got was a class file, witch can't be used, just reports that Class Hello could not be found. I've seen this symptom before. The following rules may help: - The target directory for t

Re: A stupid beginners question about Compile

2009-02-12 Thread Laurent PETIT
In a nutshell (not tested, but nothing should miss, just typos if it doesn't work) : mkdir test-compile cd test-compile mkdir classes mkdir src mkdir src/echo echo "(ns echo.test) (defn echo [msg] msg)" > src/echo/test.clj java -cp path/to/clojure.jar:src/:classes/ clojure.lang.Repl user> (compile

Re: A stupid beginners question about Compile

2009-02-12 Thread Craig McDaniel
Have a look at how the clojure-contrib project is compiled. The build.xml file will help. --~--~-~--~~~---~--~~ 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: Reading... from a reader

2009-02-12 Thread Stephen C. Gilardi
On Feb 12, 2009, at 3:39 PM, Phil Hagelberg wrote: I'm no Java IO expert, but it sounds like a BufferedReader is the right thing in the majority of cases. I think having "read" wrap its stream in a PushbackReader where necessary is a much better, non-intrusive solution, and my implementatio

generated class with overloaded methods

2009-02-12 Thread Craig McDaniel
For the benefit of others, since this took me a while to understand... When using gen-class to extend or implement a superclass with overloaded methods, use a single multi-arity function to override the overloaded methods in the superclass: expmeth/ClassA.java: package expmeth; public class Clas

A stupid beginners question about Compile

2009-02-12 Thread anderspe
Hi! I have tried to compile a simple "Hello World" but the closest a got was a class file, witch can't be used, just reports that Class Hello could not be found. Does anyone have time to tell me step by step how-to I am new to LISP and Clojure but not to Java. --~--~-~--~~

Re: let and binding have different ordering behavior

2009-02-12 Thread Phil Hagelberg
Mark Volkmann writes: >> Whoops, this caught me today. Whereas "let" evaluates its bindings >> sequentially, "binding" does not! Observe: >> >> (def a "a1") >> (def b "b1") >> >> (let [a "a2", b a] b) >> ;;=> "a2" >> >> (binding [a "a2", b a] b) >> ;;=> "a1" >> >> I wouldn't call this a bug, b

Re: let and binding have different ordering behavior

2009-02-12 Thread Mark Volkmann
On Thu, Feb 12, 2009 at 3:26 PM, Stuart Sierra wrote: > > Whoops, this caught me today. Whereas "let" evaluates its bindings > sequentially, "binding" does not! Observe: > > (def a "a1") > (def b "b1") > > (let [a "a2", b a] b) > ;;=> "a2" > > (binding [a "a2", b a] b) > ;;=> "a1" > > I wouldn'

let and binding have different ordering behavior

2009-02-12 Thread Stuart Sierra
Whoops, this caught me today. Whereas "let" evaluates its bindings sequentially, "binding" does not! Observe: (def a "a1") (def b "b1") (let [a "a2", b a] b) ;;=> "a2" (binding [a "a2", b a] b) ;;=> "a1" I wouldn't call this a bug, but I think it's worth noting in the doc string for "binding

More Swing Examples

2009-02-12 Thread Harrison Maseko
Hello, where can I find more Swing examples for Clojure? hm --~--~-~--~~~---~--~~ 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 To unsubscribe from this group

Re: error running example

2009-02-12 Thread Harrison Maseko
Thanks for your help, it worked. On Feb 12, 12:15 am, Harrison Maseko wrote: > OK. Let me try that. > > On Feb 11, 11:09 pm, Shawn Hoover wrote: > > > On Wed, Feb 11, 2009 at 3:10 PM, Harrison Maseko wrote: > > > > Hi everyone, > > > I just downloaded Clojure Box today and tried to run the exa

Re: How to build tree with nodes that 'point' to each other?

2009-02-12 Thread kyle smith
I tackled this exact problem a few days ago. My solution was to use atoms (very poorly). My code is on the group as bsptree.clj --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread kyle smith
+1 as well for pipe and let-> --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsub

Reflection warnings starting at r1265

2009-02-12 Thread Vincent Foley
Hello, I was surprised today to see that my Starcraft replay program became slower when I updated my Clojure working copy. About a week ago, Chouser helped me adding type hints to avoid reflection in my functions. The warnings came back today. I started going through the different revisions of

Re: Reading... from a reader

2009-02-12 Thread Phil Hagelberg
Mark Fredrickson writes: > While (read) taking an argument seems valid, I think you can do what > you want in the short term using binding: read actually already takes an argument, it just (without my patch) requires it to be a PushbackReader. > IIRC, duck-streams has a (with-reader ...) form

Re: understanding lazy sequences

2009-02-12 Thread Mark Volkmann
On Thu, Feb 12, 2009 at 12:22 PM, Meikel Brandmeyer wrote: > Hi, > > Am 12.02.2009 um 18:29 schrieb Mark Volkmann: > >> (def f-infinite-seq (map f (iterate inc 0))) ; values 0 through infinity >> >> (println "The first is" (first f-infinite-seq)) >> (println "The third is" (nth f-infinite-seq 2))

Re: Reading... from a reader

2009-02-12 Thread Phil Hagelberg
Stuart Sierra writes: > I could change "duck-streams/reader" to return a PushbackReader > instead of a BufferedReader. Unfortunately, "readLine" is defined in > BufferedReader but NOT in PushbackReader. We need "readLine" for > "clojure.core/line-seq". So we can't have it both ways. Blame Ja

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread MattH
+1 for pipe and let-> as above, with the non-seq => (non-seq local) translation. --~--~-~--~~~---~--~~ 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 To unsubs

Re: JTable howto

2009-02-12 Thread what-a-guy
Thanks for the help! The code comes from the Java tutorials at http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#headertooltip which compiles and runs as advertised on my system. Here's an attempt to use it in clojure, which does display the table correctly, but the prn

Re: A Clojure documentation browser

2009-02-12 Thread Craig Andera
> Nice work! Thanks. > Two things related to 'strcat'. > > 1) This is already implemented as clojure.core/str (and is more > efficient than concat'ing) > 2) This function is never called :) Yeah, that code was cut and pasted from some older work I did. It was removed when I started using prxml.

Re: How to build tree with nodes that 'point' to each other?

2009-02-12 Thread Jason Wolfe
I think there are two basic ways to do this. One is to use one of the mutable Clojure types mentioned above (or any mutable Java type) to make an actually circular structure, as you describe. For instance, you could accomplish (almost) what you want if :parent is an atom. The other way is to gi

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread Perry Trolard
Let me amend: Instead of pipe-as, I think the symbol-binding version of the macro should be derived from the more common macro, which is -> & not pipe. So I'd vote for pipe & a let-> that takes a bindings vector as its first argument (sample implementation below). Perry (defmacro let-> "Like

Re: understanding lazy sequences

2009-02-12 Thread Mark Volkmann
On Thu, Feb 12, 2009 at 12:22 PM, Meikel Brandmeyer wrote: > Hi, > > Am 12.02.2009 um 18:29 schrieb Mark Volkmann: > >> (def f-infinite-seq (map f (iterate inc 0))) ; values 0 through infinity >> >> (println "The first is" (first f-infinite-seq)) >> (println "The third is" (nth f-infinite-seq 2))

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread Perry Trolard
On Feb 12, 12:15 pm, Meikel Brandmeyer wrote: > > I dislike this strategy for two related reasons: (1) It cannont be > > nested. Here is a pseudo-example: > > > (?-> 2 ... some computations ... (f (?-> ... I don't have access to > > the outer "?" anymore... ))) > > > (2) Shadowing user bindings

Re: Generic functions: things, models, and protocols revisited

2009-02-12 Thread David Nolen
Neat! You've removed the need to even define a dispatch-fn. I'll need to chew on this for a bit (I'm a little slow :) I'm still working on my attempt at implementing protocols, but I'm not totally clear on where it will go or how useful it will be. Seems like this kind of dispatch and the Datalog

Re: Questions about the Enlive template library

2009-02-12 Thread Tom Hickey
After just having a quick discussion with Rich I think the specificity discussion threw me off with regards to the functional aspect of the templates transforming the document. I'm definitely munging the two together in my examples and, at the time, my expectations. But I think I have a better id

Re: Reading... from a reader

2009-02-12 Thread Phil Hagelberg
Rich Hickey writes: > Yes. Issue/patch welcome. Great; issue and patch attachment are here: http://code.google.com/p/clojure/issues/detail?id=79&colspec=ID%20Type%20Status%20Priority%20Reporter%20Owner%20Summary I haven't written much Java, but the implementation seems pretty straightforward.

Re: Reading... from a reader

2009-02-12 Thread Stuart Sierra
On Feb 12, 12:53 pm, Phil Hagelberg wrote: > I'd expect to be able to do (read (reader my-file)), but this isn't OK > because read needs a java.io.PushbackReader. It seems vaguely wrong > somehow to have a function called "reader" return something that cannot > be "read" from. I could change "du

Re: Questions about the Enlive template library

2009-02-12 Thread Tom Hickey
Hi Christophe, Thank you for the quick reply! Snippets I think what you have suggested for snippets sounds perfect. Using [selector to single out this snippet] from within a file is definitely way better then what I was envisioning. I think having the ability to define a single snippet as well a

Re: Reading... from a reader

2009-02-12 Thread Mark Fredrickson
While (read) taking an argument seems valid, I think you can do what you want in the short term using binding: (binding [*in* my-reader] (print (read))) It has been my general observation that vars + binding in Clojure fill the niche that optional arguments fill in other languages. While it ma

Re: understanding lazy sequences

2009-02-12 Thread Meikel Brandmeyer
Hi, Am 12.02.2009 um 18:29 schrieb Mark Volkmann: (def f-infinite-seq (map f (iterate inc 0))) ; values 0 through infinity (println "The first is" (first f-infinite-seq)) (println "The third is" (nth f-infinite-seq 2)) The result is cached in f-infinite-seq. So as long as you hold onto the

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread Meikel Brandmeyer
Hi, Am 12.02.2009 um 16:15 schrieb Mark Fredrickson: I dislike this strategy for two related reasons: (1) It cannont be nested. Here is a pseudo-example: (?-> 2 ... some computations ... (f (?-> ... I don't have access to the outer "?" anymore... ))) (2) Shadowing user bindings. If I bind ? t

Re: Reading... from a reader

2009-02-12 Thread Phil Hagelberg
Phil Hagelberg writes: > I've got a problem where I have a reader (it's a java.io.BufferedReader > that came from duck-streams, if that matters at all) and I want to call > "read" on it. I should mention that I know *how* to do this: (read (java.io.PushbackReader. (reader file))) I just thi

Re: Reading... from a reader

2009-02-12 Thread Rich Hickey
On Feb 12, 2009, at 12:53 PM, Phil Hagelberg wrote: > > > I've got a problem where I have a reader (it's a > java.io.BufferedReader > that came from duck-streams, if that matters at all) and I want to > call > "read" on it. > > I'd expect to be able to do (read (reader my-file)), but this is

Reading... from a reader

2009-02-12 Thread Phil Hagelberg
I've got a problem where I have a reader (it's a java.io.BufferedReader that came from duck-streams, if that matters at all) and I want to call "read" on it. I'd expect to be able to do (read (reader my-file)), but this isn't OK because read needs a java.io.PushbackReader. It seems vaguely wrong

Re: My SLIME installation diary

2009-02-12 Thread Phil Hagelberg
bOR_ writes: >>> (push "/home/boris/.emacs.d" load-path) >>This is actually already on the load-path by default; no need to add it. > > Standard load-path on ubuntu didn't include ~/.emacs.d for me. Not > sure why not. You're right; my bad. > 1. Creating a .emacs with the load-path .emacs.d >

understanding lazy sequences

2009-02-12 Thread Mark Volkmann
Here's some simple code that demonstrates evaluation of items in an infinite, lazy sequence. The function f contains a println side-effect so I know when it's being called. (defn f "square the parameter and divide by 2" [x] (println "calculating f of" x) (/ (* x x) 2.0)) ; Create an infi

one more article ! :-)

2009-02-12 Thread Laurent PETIT
http://www.infoq.com/news/2009/02/jruby-clojure Even if I'm a daily java programmer, I like the following sentence a lot : "Choosing a lower level, system language, be it C (for MRI) or Java (for JRuby)" , justifying to use clojure when JRuby needs performance (!) while still using a "high level

Re: how can I do this?

2009-02-12 Thread wubbie
thaks everyone! -sun On Feb 12, 11:59 am, Laurent PETIT wrote: > Hello, > > one solution : java API to the rescue : > > (defn digits [s] (apply str (filter #(Character/isDigit %) s))) > > or > > (def digits (comp (partial apply str) (partial filter #(Character/isDigit > % > > if you prefer

Re: how can I do this?

2009-02-12 Thread Laurent PETIT
Hello, one solution : java API to the rescue : (defn digits [s] (apply str (filter #(Character/isDigit %) s))) or (def digits (comp (partial apply str) (partial filter #(Character/isDigit % if you prefer a more haskellish form :-) 2009/2/12 wubbie > > Hello, > > How can I do this? Do we

Re: how can I do this?

2009-02-12 Thread Christophe Grand
wubbie a écrit : > Hello, > > How can I do this? Do we have a function that checks if > it's a char or digit? > > (digits "a2c3") > -> "23" Many predicates on characters are defined in java.lang.Character: http://java.sun.com/javase/6/docs/api/java/lang/Character.html user=> (apply str (filter #(

how can I do this?

2009-02-12 Thread wubbie
Hello, How can I do this? Do we have a function that checks if it's a char or digit? (digits "a2c3") -> "23" Thanks, sun --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread Mark Fredrickson
> There seems to be a general consensus that some sort of explicit form of threading would be useful. Below are snippets of other messages, outlining the remaining points. I should point out that we are not limited to one macro/function to handle our needs. For my own part, I think as wri

Re: problem with imports inside a binding block

2009-02-12 Thread Stephen C. Gilardi
On Feb 12, 2009, at 4:21 AM, Albert Cardona wrote: I may be missing something fundamental about "binding", because I can't understand how the imports fail inside the binding block: [this works] But this doesn't (restarted the Repl to remove imports): user=> (import '(java.io StringWriter

Re: Questions about the Enlive template library

2009-02-12 Thread Christophe Grand
Christophe Grand a écrit : > Tom Hickey a écrit : > >> What about grouping selectors? >> > Patch welcome :-) > Done. #{[selector1] [selector2]} is selector1, selector2 I also added selector-steps union: [#{:h1 :h2 :h3} :a] is h1 a, h2 a, h3 a Christophe -- Professional: http://cgra

Re: patch to improve startup time on low end hardware

2009-02-12 Thread Remco van 't Veer
Created issued including patch: http://code.google.com/p/clojure/issues/detail?id=78 The CA is in the mail. On Wed, Feb 11, 2009 at 2:08 PM, Rich Hickey wrote: > > > > On Feb 11, 4:36 am, "Remco van 't Veer" wrote: >> On Tue, Feb 10, 2009 at 1:57 PM, Remco van 't Veer >> wrote: >> >> >>

Re: is mod correct?

2009-02-12 Thread Timothy Pratley
> The real hit would come with bignums, no? But as far as the routine   > use of MOD goes we're probably talking about fixnums > 99% of the time. Good point, I tried some more timings on various configurations: ; Currently submitted (soon to be dethroned) patch (defn mod1 "Modulus of num and d

Re: r1265 causes VerifyError on dalvik

2009-02-12 Thread Remco van 't Veer
Done: http://code.google.com/p/clojure/issues/detail?id=77 On Thu, Feb 12, 2009 at 2:06 PM, Rich Hickey wrote: > > > > On Feb 12, 5:30 am, "Remco van 't Veer" wrote: >> Should I open in issue for this? >> >> W/dalvikvm( 214): VFY: unable to resolve virtual method 6650: Ljava/ >> lang/StringBu

Re: is mod correct?

2009-02-12 Thread Frantisek Sodomka
There are also unchecked versions. Don't know if they are needed at this moment. We have unchecked-remainder, but there isn't unchecked- quotient or unchecked-modulo. I added tests for mod, rem & quot to test-clojure.numbers: http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojur

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread Timothy Pratley
Dare I suggest it <- might be an interesting 'name' for 'pipe' given that -> calls in prefix and 'pipe' calls in postfix. But I'd rather not see it contending with Datalog which <- is nice to use. | isn't 'official', but it works fine... > and < aren't 'officially' usable in symbols either so wh

Re: r1265 causes VerifyError on dalvik

2009-02-12 Thread Rich Hickey
On Feb 12, 5:30 am, "Remco van 't Veer" wrote: > Should I open in issue for this? > > W/dalvikvm( 214): VFY: unable to resolve virtual method 6650: Ljava/ > lang/StringBuilder;.append (C)Ljava/lang/AbstractStringBuilder; > W/dalvikvm( 214): VFY: rejecting opcode 0x6e at 0x0043 > W/dalvikvm(

Re: is mod correct?

2009-02-12 Thread David Sletten
On Feb 10, 2009, at 6:37 PM, Timothy Pratley wrote: > > I would have expected the mult to be a performance hit, but my overly > simple tests show it performing better: > user=> (time (dotimes [i 100] (zero? (* 5 11 > "Elapsed time: 183.358706 msecs" > user=> (time (dotimes [i 100] (o

Re: Got a Clojure library?

2009-02-12 Thread Rich Hickey
On Feb 11, 10:34 pm, Jeffrey Straszheim wrote: > I'd love to add Clojure-Datalog. I'm still working on it, but it now > implements complete Datalog rules, including stratified negation and > boolean filters. It can now be used for basic tasks, although the > interface is rough. > > Name: Cloj

Re: How to build tree with nodes that 'point' to each other?

2009-02-12 Thread verec
You night want to consider this: user=> (def m {:myself nil :yourself 'moo}) #'user/m user=> m {:myself nil, :yourself moo} user=> (def m2 (assoc m :myself m)) #'user/m2 user=> m {:myself nil, :yourself moo} user=> m2 {:myself {:myself nil, :yourself moo}, :yourself moo} Now, if :myself' value w

Re: Anonymous classloading in JDK 6u14

2009-02-12 Thread Rich Hickey
On Feb 11, 6:48 pm, pmf wrote: > Hi, > > I have just read about the upcoming JDK 6u14 [1], which mentions that > one of the features is support for loading anonymous classes [2]. > > Is this being considered for Clojure? I couldn't really extract from > the article whether this is backwards-com

Re: How to build tree with nodes that 'point' to each other?

2009-02-12 Thread MattH
You might want to check out zippers, which give you the ability to navigate and 'edit' a tree structure, but using immutable data structures. There are some good explanations on this thread: http://groups.google.com/group/clojure/browse_thread/thread/d8871da625420b71/1bce7c6d9def2031 --~--~--

Re: is mod correct?

2009-02-12 Thread Timothy Pratley
On Feb 12, 10:47 pm, Frantisek Sodomka wrote: > Also, "mod" seems too strict about numbers it accepts (only > integers!): *chuckle* indeed, why be so strict! Removed the integer checks, hey it is looking really similar to SBCL now o_O http://clojure.googlecode.com/issues/attachment?aid=-820378

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread MattH
"Plus a macro makes for shorter syntax, which is part of its purpose." Yeah the shorter syntax becomes even more apparent when you're piping/ threading through one-arg functions where it also saves on parenthesis, as the "->" and "pipe" macros expand to a list if necessary. E.g. this code in a c

Re: is mod correct?

2009-02-12 Thread Frantisek Sodomka
Also, "mod" seems too strict about numbers it accepts (only integers!): user=> (rem 1 2/3) 1/3 user=> (mod 1 2/3) java.lang.IllegalArgumentException: mod requires two integers (NO_SOURCE_FILE:0) user=> (rem 4.5 2.0) 0.5 user=> (mod 4.5 2.0) java.lang.IllegalArgumentException: mod requires two in

Re: Questions about the Enlive template library

2009-02-12 Thread Christophe Grand
Christophe Grand a écrit : > Universal and attribute selectors can be easily added. > I added :* (universal), attr= and attr? [:body :> :*] ; body > * [[:a (attr= :href "http://google.com";)]] ; a[href="http://google.com";] [[:a (attr? :href)]] ; a[href] >> 4) Attributes >> Do you hav

Re: Questions about the Enlive template library

2009-02-12 Thread Christophe Grand
Hi Tom! Thanks for your interest in Enlive. Tom Hickey a écrit : > I am trying out Enlive and had some questions regarding it's feature > set and your future plans in terms of functionality. > I grow it as I go: I haven't a clearly outlined future features list (I'm thinking about JS/jQuery

Generic functions: things, models, and protocols revisited

2009-02-12 Thread mikel
David Nolen and I were recently discussing CLOS and method dispatch. I implemented such a scheme for my own use. This post is an FYI for David and anyone else who might be interested in generic functions and predicate dispatch. Here's a transcript of a sample session in which I exercise the dispa

Re: How to build tree with nodes that 'point' to each other?

2009-02-12 Thread bOR_
Not a guru here (far from!), but don't get too thrown off by what the word 'immutable' means in your head. In Clojure 'immutable' refers more to how things work in the belly of the beast.. Clojure has 4 constructs (vars, refs, agents and atoms) to faciliate mutating things. Probably the best thin

r1265 causes VerifyError on dalvik

2009-02-12 Thread Remco van 't Veer
Should I open in issue for this? W/dalvikvm( 214): VFY: unable to resolve virtual method 6650: Ljava/ lang/StringBuilder;.append (C)Ljava/lang/AbstractStringBuilder; W/dalvikvm( 214): VFY: rejecting opcode 0x6e at 0x0043 W/dalvikvm( 214): VFY: rejected Lclojure/core$slurp__4218;.invoke (Ljav

problem with imports inside a binding block

2009-02-12 Thread Albert Cardona
I may be missing something fundamental about "binding", because I can't understand how the imports fail inside the binding block: This works: user=> (import '(java.io StringWriter)) nil user=> (def bout (StringWriter.)) #'user/bout user=> (bind

How to build tree with nodes that 'point' to each other?

2009-02-12 Thread timc
I'm new to Clojure so this may be a stupid question. I want to make a tree out of these things: (defstruct treeNode :parent :children :data) so that every node knows which node is its parent and which nodes are its children. But, given that these things are immutable, I am baffled as to how th

Re: A pipe macro for left-to-right coll streams

2009-02-12 Thread Konrad Hinsen
On 11.02.2009, at 18:18, Perry Trolard wrote: > In any case, I vote for approaching Konrad Hinsen about putting this > in clojure.contrib.macros when a naming convention is agreed on. When I started clojure.contrib.macros, I intended it as a repository for everybody's small macros that don't h