Re: filter-split

2009-03-08 Thread Laurent PETIT
It seems to me that neither filt-split nor filter-rem from e are lazy operations (one uses reduce, the other one uses recur). The version in clojurecontrib seems to preserve the original property of filter of returning a lazy sequence. My 0,02€, -- Laurent 2009/3/8 Adrian Cuthbertson

Re: defining types and interfaces

2009-03-08 Thread Konrad Hinsen
On 08.03.2009, at 00:14, mikel wrote: You can do a lot of that in Clojure, too, but, unless I'm mistaken, there are some arbitrary limits as things stand right now. I don't know of a way in Clojure to define an interface; as far as I know, if Multimethods can be used very well to define

Re[2]: hash-map based on identity

2009-03-08 Thread David Powell
Identity is tested first in equality, if identical, equal, full stop. That's what I'd assumed (it's what the JDK collections do), but looking at the code, to say, APersistentVectory, I can't see where the identity test is done? Am I looking in the wrong place? -- Dave

Re: filter-split

2009-03-08 Thread Adrian Cuthbertson
Sorry, further to that last example, if you actually consume all of both even and odd sets then the reduce version is more efficient... (time (let [[a b] (filt-split even? (range 10))] [(nth a 4) (nth b 4)])) Elapsed time: 36.711 msecs [8 9] (time (let [[a b] (separate even?

Re: filter-split

2009-03-08 Thread Christophe Grand
The question showed up the other day on #clojure with the additional constraint to evaluate pred only once per item, here is Rich's solution: http://paste.lisp.org/display/76458#1 (defn unzip-with [pred coll] (let [pvs (map #(vector (pred %) %) coll)] [(for [[p v] pvs :when p] v)

Re: filter-split

2009-03-08 Thread Adrian Cuthbertson
Hmm, on the same (micro admittedly) benchmark as above... (time (let [[a b] (unzip-with even? (range 10))] [(nth a 4) (nth b 4)])) Elapsed time: 177.797 msecs [8 9] that's a bit slower than both the previous versions. The reduce version does only apply the pred once per item

Re: filter-split

2009-03-08 Thread e
(filt-rem identity '(true nil false 8)) = ((true) ()) (filt-split identity '(true nil false 8)) = [[true 8] [nil false]] can't speak for this one, cause I don't know enough clojure (filt-rem even? (range 10)) = ((8 6 4 2 0) (9 7 5 3 1)) (filter-split even? (range 10)) = [(0 2 4 6 8) (1 3 5

Re: defining types and interfaces

2009-03-08 Thread Meikel Brandmeyer
Hello Name-cousin, :) Am 08.03.2009 um 08:10 schrieb mikel: Now suppose I want to create some new objects that have all of those advantages, but the interfaces that I want them to conform to don't yet exist. How do I supply them? As far as I know, I have to write Java code. I'd rather write

Re: filter-split

2009-03-08 Thread e
This is exactly what I'm trying to avoid. I don't want to traverse the collection twice. In that other thread, Time lies, even with doall, someone helped me figure out a way to get the true time for filter-split, and concluded it was 2- 3 times faster than whats in contrib as expected . . .

Re: defining types and interfaces

2009-03-08 Thread mikel
On Mar 8, 6:20 am, Meikel Brandmeyer m...@kotka.de wrote: Hello Name-cousin, :) Woohoo! Am 08.03.2009 um 08:10 schrieb mikel: Now suppose I want to create some new objects that have all of those advantages, but the interfaces that I want them to conform to don't yet exist. How do I

Re: filter-split

2009-03-08 Thread e
On Sun, Mar 8, 2009 at 6:48 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 08.03.2009 um 11:44 schrieb Adrian Cuthbertson: that's a bit slower than both the previous versions. The reduce version does only apply the pred once per item I think? unzip-with is lazy, the reduce version is

Capitalize string

2009-03-08 Thread David Sletten
Is there a function to capitalize the first letter of a string or a better way than this idiotic code? (apply str (map #(if (zero? %2) (Character/toUpperCase %1) %1) clojuriffic (iterate inc 0))) Aloha, David Sletten --~--~-~--~~~---~--~~ You received this

transactions and deadlock

2009-03-08 Thread Mark Volkmann
Is there a webpage or video that describes what Clojure transactions do to avoid deadlocks? I'm not having a particular issue. I just want to understand what is provided. Perhaps I just need to look at the source starting from dosync. -- R. Mark Volkmann Object Computing, Inc.

Re: Capitalize string

2009-03-08 Thread Joshua Fox
How about this? user= (defn upper-first [s] (apply str (Character/toUpperCase (first s)) (rest s))) #'user/upper-first user= (upper-first a) A On Sun, Mar 8, 2009 at 3:39 PM, David Sletten da...@bosatsu.net wrote: Is there a function to capitalize the first letter of a string or a

Re: Capitalize string

2009-03-08 Thread David Sletten
On Mar 8, 2009, at 2:45 AM, Joshua Fox wrote: How about this? user= (defn upper-first [s] (apply str (Character/toUpperCase (first s)) (rest s))) #'user/upper-first user= (upper-first a) A That certainly qualifies as less idiotic. :) Mahalo, David Sletten

Re: swank-clojure + slime

2009-03-08 Thread Lucio Fulci
First of all, make sure you use the latest versions of slime, clojure, swank-clojre and clojure-mode. It works fine for me on both linux and windows. get latest slime here - http://common-lisp.net/project/slime/ get latest swank-clojure (your version seems to be outdated) here -

Re: swank-clojure + slime

2009-03-08 Thread youngblood.carl
Thanks Lucio, but you can see on git-hub that the head version of core.clj uses lazy-seq: http://github.com/jochu/swank-clojure/blob/349cb3b93a7bd8bcc86ffd0fd5415d84ed5f4028/swank/core.clj On Mar 8, 9:02 am, Lucio Fulci luciofulc...@gmail.com wrote: First of all, make sure you use the latest

Re: swank-clojure + slime

2009-03-08 Thread Lucio Fulci
well, I'm not an expert in lisp, emacs and linux either :) the thing is that latest version of swank-clojure does work for me. On Sun, Mar 8, 2009 at 5:09 PM, youngblood.carl youngblood.c...@gmail.comwrote: Thanks Lucio, but you can see on git-hub that the head version of core.clj uses

Re: Capitalize string

2009-03-08 Thread Itay Maman
I am not particularly fond of idiomatic style. In production code I want something clear and explicit even if it is a bit longer. That said, your question triggered this challenge: What's the shortest way for capitalizing the first letter of every word, i.e.: (assert (= (capitalize ab cd) Ab Cd))

Earn more money

2009-03-08 Thread ramya menon
*EARN 300-600 DOLLARS PER MONTH WITHOUT INVESTMENT For more details please log on to http://www.moreinfo247.com/10288668/CB (instead of 9222074 use your ID) •YOU WILL BE PAID 2 US DOLLARS FOR EACH MEMBER JOINING UNDER YOU (they also should work) •TO ENROLL MEMBERS YOU CAN USE

Earn more money

2009-03-08 Thread ramya menon
*EARN 300-600 DOLLARS PER MONTH WITHOUT INVESTMENT For more details please log on to http://www.moreinfo247.com/10288668/CB (instead of 9222074 use your ID) •YOU WILL BE PAID 2 US DOLLARS FOR EACH MEMBER JOINING UNDER YOU (they also should work) •TO ENROLL MEMBERS YOU CAN USE

Earn more money

2009-03-08 Thread ramya menon
*EARN 300-600 DOLLARS PER MONTH WITHOUT INVESTMENT For more details please log on to http://www.moreinfo247.com/10288668/CB (instead of 9222074 use your ID) •YOU WILL BE PAID 2 US DOLLARS FOR EACH MEMBER JOINING UNDER YOU (they also should work) •TO ENROLL MEMBERS YOU CAN USE

http://www.stylishdudes.com cheap sell air max shoes, nike shoes,ugg shoes,jordan shoes,handbag,jeans,shox shoes,Get Nike Shoes at Super Cheap Prices

2009-03-08 Thread stylishdudes...@gmail.com
Get Nike Shoes at Super Cheap Prices Discount Nike air jordans (www.stylishdudes.com) Discount Nike Air Max 90 Sneakers (www.stylishdudes.com) Discount Nike Air Max 91 Supplier (www.stylishdudes.com) Discount Nike Air Max 95 Shoes Supplier (www.stylishdudes.com) Discount Nike Air Max 97

Earn more money

2009-03-08 Thread ramya menon
*EARN 300-600 DOLLARS PER MONTH WITHOUT INVESTMENT For more details please log on to http://www.moreinfo247.com/10288668/CB (instead of 9222074 use your ID) •YOU WILL BE PAID 2 US DOLLARS FOR EACH MEMBER JOINING UNDER YOU (they also should work) •TO ENROLL MEMBERS YOU CAN USE

Earn more money

2009-03-08 Thread ramya menon
*EARN 300-600 DOLLARS PER MONTH WITHOUT INVESTMENT For more details please log on to http://www.moreinfo247.com/10288668/CB (instead of 9222074 use your ID) •YOU WILL BE PAID 2 US DOLLARS FOR EACH MEMBER JOINING UNDER YOU (they also should work) •TO ENROLL MEMBERS YOU CAN USE

Sorry about the spam

2009-03-08 Thread Rich Hickey
Sorry about the spam. A few messages got through due to a mis-click on my part. The defenses are still fine. Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: swank-clojure + slime

2009-03-08 Thread christophe turle
Same problem here. my solution : i'm currently using Clojure Box - http://clojure.bighugh.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Capitalize string

2009-03-08 Thread Meikel Brandmeyer
Hi, Am 08.03.2009 um 15:26 schrieb Itay Maman: (assert (= (capitalize ab cd) Ab Cd)) ? Here's my take: (defn capitalize [s] (apply str (map (fn [prev curr] (or (and (= prev \space) (Character/toUpperCase curr)) curr)) (cons \space s) s))) That's mine: (defn capitalize [words]

Re: Capitalize string

2009-03-08 Thread Stuart Sierra
On Mar 8, 9:39 am, David Sletten da...@bosatsu.net wrote: Is there a function to capitalize the first letter of a string or a   better way than this idiotic code? Once again, Apache Commons to the rescue: http://tinyurl.com/d38wwq (StringUtils/capitalize clojure) ;;= Clojure -Stuart Sierra

On the importance of recognizing and using maps

2009-03-08 Thread Rich Hickey
It's great to see all of the Clojure libraries springing up as people pull Clojure towards their application domains, and shape it for the styles of programming they prefer. In looking at some of the libraries, I am a bit concerned that maps are not being used when the logical entity is in fact

Re: swank-clojure + slime

2009-03-08 Thread Rob Wolfe
youngblood.carl napisał(a): Thanks Lucio, but you can see on git-hub that the head version of core.clj uses lazy-seq: http://github.com/jochu/swank-clojure/blob/349cb3b93a7bd8bcc86ffd0fd5415d84ed5f4028/swank/core.clj I read somewhere too that lazy-seq dissapeared from clojure and that is

Re: Clojure + Terracotta: We Have REPL!

2009-03-08 Thread Rich Hickey
On Mar 5, 4:23 pm, Paul Stadig p...@stadig.name wrote: I had one last, major hurdle, and was helped by Chouser (thank you!). http://paul.stadig.name/2009/03/clojure-terracotta-we-have-repl.html Still lots more to do, and probably some simple changes that could be rolled back into the

Re: On the importance of recognizing and using maps

2009-03-08 Thread Stuart Sierra
On Mar 8, 1:53 pm, Rich Hickey richhic...@gmail.com wrote: I really appreciate the work everyone is doing, just trying to maintain 'everything works with everything' with a nudge towards more consistent use of maps. Don't build your API on an island. And a good nudge it is! This reminds me

Re: transactions and deadlock

2009-03-08 Thread André Thieme
On 8 Mrz., 13:40, Mark Volkmann r.mark.volkm...@gmail.com wrote: Is there a webpage or video that describes what Clojure transactions do to avoid deadlocks? I'm not having a particular issue. I just want to understand what is provided. Perhaps I just need to look at the source starting from

Re: LazyMap v2.2 released

2009-03-08 Thread André Thieme
On 7 Mrz., 18:38, Meikel Brandmeyer m...@kotka.de wrote: Dear Clojurians, I'd like to announce release of LazyMap v2.2. New in this release are:   * compatibility with lazy-seq changes   * LazyMapSeq now inherits from ASeq   * 100% reflection free The release maybe found at the usual

Re: swank-clojure + slime

2009-03-08 Thread Phil Hagelberg
youngblood.carl youngblood.c...@gmail.com writes: Thanks Lucio, but you can see on git-hub that the head version of core.clj uses lazy-seq: http://github.com/jochu/swank-clojure/blob/349cb3b93a7bd8bcc86ffd0fd5415d84ed5f4028/swank/core.clj The lazy-seq macro is what replaced lazy-cons.

filter1 interesting?

2009-03-08 Thread André Thieme
I regularily stumble upon the (first (filter predicate coll)) pattern. Maybe we can add a filter1 for that? In the Clojure project itself I found this two times, in core.clj for the ns macro, and in genclass.clj in find-field. Also in the clojure-contrib project it shows up two times (again in

Promise for absense of side effects

2009-03-08 Thread André Thieme
I like that Clojure is a dynamically typed language. Even in dynamic languages it is possible to find out a lot more about the code itself than one may think on a first glance. Clojure already supports type hints that can make code run faster. But what if we could add a soft layer of static

Re: On the importance of recognizing and using maps

2009-03-08 Thread Dan
I guess I want to advocate - don't merely replicate the things with which you are familiar. Try to do things in the Clojure way. If your logical structure is a mapping of names to values, please use a map. I tend to replace every instance of creating classes with creating structs which, if I

Re: On the importance of recognizing and using maps

2009-03-08 Thread David Nolen
Structs are maps with shared keys and positional constructors as Rich mentions in the original post. I think Rich is saying that maps should indeed be abused ;) By building all higher level structures on top of them, consumers are guaranteed not only your custom functionality, but all the

Re: swank-clojure + slime

2009-03-08 Thread Paul Stadig
On Sun, Mar 8, 2009 at 3:15 PM, Phil Hagelberg p...@hagelb.org wrote: It sounds more likely that your copy of Clojure is out of date. Are you pulling from the sourceforge SVN by any chance? It would probably be a good idea to make it so the last commit in the SF repo is simply a README

Re: On the importance of recognizing and using maps

2009-03-08 Thread Phil Hagelberg
Dan redalas...@gmail.com writes: I guess I want to advocate - don't merely replicate the things with which you are familiar. Try to do things in the Clojure way. If your logical structure is a mapping of names to values, please use a map. I tend to replace every instance of creating classes

Re: swank-clojure + slime

2009-03-08 Thread youngblood.carl
Phil, I am much obliged for the detailed help. I downloaded clojure as the archive available from google code rather than using svn. So the docs at http://clojure.org/api are out of date then? Thanks, Carl On Mar 8, 2:15 pm, Phil Hagelberg p...@hagelb.org wrote: youngblood.carl

Is proxy the right tool for this job ? Cyclic vector ? Proxy bug ?

2009-03-08 Thread Paul Mooser
I was playing around with some project euler problems, and I was thinking that the cycle function has an analog for vectors. I implemented a short simple method with the right behavior (at a simple surface level): (defn cyclic-vector [v] (fn [x] (v (mod x (count v) However, this

Re: On the importance of recognizing and using maps

2009-03-08 Thread Dan
I'm pretty sure structs are only appropriate for when you need to eek the absolute last iota of performance out of a collection, in which case they can provide greater speed than maps. But since the list of keys is fixed, it means it's more effort to add or rename a key than it is with a

Re: On the importance of recognizing and using maps

2009-03-08 Thread Mark Allerton
I'm kind of a newb to these parts, but I disagree somewhat with Phil that structmaps are only useful as a performance optimization. It also seems to me that because they make it convenient to create positional constructors for map structures, they make life much easier to concisely build data

Re: Is proxy the right tool for this job ? Cyclic vector ? Proxy bug ?

2009-03-08 Thread Timothy Pratley
For your eueler problem consider using lazy functions cycle and range: user= (take 15 (cycle (range 5))) (0 1 2 3 4 0 1 2 3 4 0 1 2 3 4) Or is there some other behavior you need to create? Regarding proxy your main problem is that IPersistentVector is an Interface (no implementation) so you

Re: On the importance of recognizing and using maps

2009-03-08 Thread Stephen C. Gilardi
On Mar 8, 2009, at 1:53 PM, Rich Hickey wrote: First up is contrib.sql, where insert-rows and insert-values both take a vector of column names followed by vectors of unlabeled values that must be in the same order as the corresponding columns. I would hope never to have such fragile things as

Re: Workflow poll?

2009-03-08 Thread Chas Emerick
On Mar 7, 2009, at 3:53 PM, Mark Engelberg wrote: Anyone using IntelliJ or Netbeans as their primary development environment, or is that stuff too experimental? We've been using enclojure in NetBeans since we started using clojure seriously. IMO, one should definitely track the hot builds

Re: On the importance of recognizing and using maps

2009-03-08 Thread Shawn Hoover
On Sun, Mar 8, 2009 at 6:13 PM, Dan redalas...@gmail.com wrote: I'm pretty sure structs are only appropriate for when you need to eek the absolute last iota of performance out of a collection, in which case they can provide greater speed than maps. But since the list of keys is fixed, it

categorizing forms

2009-03-08 Thread Mark Volkmann
I made an attempt at categorizing all special forms, functions and macros in clojure.core, plus some outside that namespace. See http://www.ociweb.com/mark/clojure/ClojureCategorized.html. I'd love some feedback on the names of the categories and whether I've split them up correctly. I think a

Exception in thread main java.lang.Exception: Too many arguments to def

2009-03-08 Thread Zonbi
Exception in thread main java.lang.Exception: Too many arguments to def (test.clj:26) both (def test-list (list (:one :two :three))) and (def test-list '(:one :two :three)) and changing the one/two/three into strings also gives me the error on running. I don't get the error using the REPL.

Exception in thread main java.lang.Exception: Too many arguments to def

2009-03-08 Thread Zonbi
Exception in thread main java.lang.Exception: Too many arguments to def (test.clj:26) both (def test-list (list (:one :two :three))) and (def test-list '(:one :two :three)) and changing the one/two/three into strings also gives me the error on running. I don't get the error using the REPL.

Re: categorizing forms

2009-03-08 Thread Aaron Brooks
Mark, I've thought about doing this in the past (partially for my own reference) but never got around to it. Thanks so much for your effort! It might be beneficial to make the function names links to the API reference. I also found it a little hard when scanning the functions to clearly

Re: On the importance of recognizing and using maps

2009-03-08 Thread Stephen C. Gilardi
On Mar 8, 2009, at 9:13 PM, Shawn Hoover wrote: Close... you can assoc new keys into a struct instance, but you can't dissoc any of the basis keys. That's right. Given: user= (defstruct foo :a :b) #'user/foo user= (def t (struct foo 3)) #'user/t dissoc of a

Re: On the importance of recognizing and using maps

2009-03-08 Thread Rich Hickey
On Mar 8, 10:10 pm, Stephen C. Gilardi squee...@mac.com wrote: On Mar 8, 2009, at 9:13 PM, Shawn Hoover wrote: Close... you can assoc new keys into a struct instance, but you can't dissoc any of the basis keys. That's right. Given: user= (defstruct foo :a :b)

Re: hash-map based on identity

2009-03-08 Thread Rich Hickey
On Mar 8, 6:17 am, David Powell djpow...@djpowell.net wrote: Identity is tested first in equality, if identical, equal, full stop. That's what I'd assumed (it's what the JDK collections do), but looking at the code, to say, APersistentVectory, I can't see where the identity test is done?

Re: On the importance of recognizing and using maps

2009-03-08 Thread Stephen C. Gilardi
On Mar 8, 2009, at 9:38 PM, Rich Hickey wrote: Do you have a case where the map-unpacking dominates the I/O time? Or is this just a speculative optimization? I was talking about the distinction between sending N value sets across the JDBC interface in one call vs. in N calls. Unpacking

Re: categorizing forms

2009-03-08 Thread samppi
I like it; it's making me realize the existence of a bunch of functions I've never considered before. If it's practical, consider doing color-coding or somehow indicating the types of the forms: special forms, macros, and functions. :) On Mar 8, 6:30 pm, Mark Volkmann r.mark.volkm...@gmail.com

Help?

2009-03-08 Thread Timothy McDowell
Exception in thread main java.lang.Exception: Too many arguments to def (test.clj:26) both (def test-list (list (:one :two :three))) and (def test-list '(:one :two :three)) and changing the one/two/three into strings also gives me the error on running. I don't get the error using the REPL. Bug?

Re: Help?

2009-03-08 Thread Zonbi
;;helpers;; (defn ++ [x] (inc x)) ;;infinite-counting;; (defn infinite-counting [start] (while true (loop [count start] (println (str count !)) (recur (++ count) ;;fibbonaci;; ; 1 1 2 3 5 8 13 etc. (prevprev + current = next) (defn count-fibbonaci []

Re: Help?

2009-03-08 Thread Stephen C. Gilardi
On Mar 8, 2009, at 10:52 PM, Zonbi wrote: (def list-length [x] Gives the length of a list using 'give-me- This is the line it's complaining about. The complaint is too many args to def. You wanted defn there. --Steve smime.p7s Description: S/MIME cryptographic signature

Re: Help?

2009-03-08 Thread Timothy McDowell
... wow. I really need to fix the line numbers on my Emacs _ Thanks a ton! On Sun, Mar 8, 2009 at 9:06 PM, Stephen C. Gilardi squee...@mac.com wrote: On Mar 8, 2009, at 10:52 PM, Zonbi wrote: (def list-length [x] Gives the length of a list using 'give-me- This is the line it's

Re: Is proxy the right tool for this job ? Cyclic vector ? Proxy bug ?

2009-03-08 Thread Paul Mooser
I actually mentioned the cycle function in my message, and that's what I was using, but the original question came up because accessing the nth item in a list takes linear rather than constant time. I'd be interested to hear how what I was attempting violates the spirit of clojure. I was trying

Re: On the importance of recognizing and using maps

2009-03-08 Thread mikel
On Mar 8, 12:53 pm, Rich Hickey richhic...@gmail.com wrote: Recently it was said in a thread: You can do a lot of that in Clojure, too, but, unless I'm mistaken, there are some arbitrary limits as things stand right now. ... you can have any kind of structure you want, as long as it's a

Re: float vs fraction (just playing around)

2009-03-08 Thread Mark H.
On Mar 6, 8:06 pm, David Sletten da...@bosatsu.net wrote: It comes as no surprise that certain numbers cannot be represented by   a finite string of decimal digits. We all realize that 1/3 =   0...., and the ... part is critical. Take it away and the   equality goes away too. In other