Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread Meikel Brandmeyer
Hi Randall, Am 12.12.2008 um 23:29 schrieb Randall R Schulz: I guess what you should say at least is that it requires Ruby and the Vim Ruby module / extension / whatever. Unfortunately, neither of the systems I use have that in their Vim builds. From the vim.org page, where you can download

Re: iteration idioms

2008-12-13 Thread Stephen Parker
On 12 Dec 2008, at 23:10, Mark Fredrickson wrote: For (2), say I want to insert 3 before every item less than or equal to 5 in a seq: Again reduce to the rescue: (reduce into (map (fn [i] (if (= i 5) [3 i] [i])) [24 6 5 5 7 5 8 2])) Could use mapcat: (def bar [24 6 5 5 7 5 8 2])

Bug in read-line?

2008-12-13 Thread Michel Salim
Using up-to-date clojure and swank-clojure, I've not been able to use read-line: - In Emacs (with Slime / swank-clojure), (read-line) never stops consuming inputs - Running clojure directly from a terminal console, (read-line) always returns This exception is also thrown when starting Swank:

Re: iteration idioms

2008-12-13 Thread Dave Newton
--- On Sat, 12/13/08, Stephen Parker wrote: On 12 Dec 2008, at 23:10, Mark Fredrickson wrote: [...] insert 3 before every item less than or equal to 5 in a seq: (def bar [24 6 5 5 7 5 8 2]) (insert-before-if #(= 5 %) 3 bar) = (3 24 3 6 3 5 3 5 3 7 3 5 3 8 2) Er... Dave

Re: Functional programming newbie question

2008-12-13 Thread lpetit
Yes, the semantics of a sequence force it to be immutable : Seqs differ from iterators in that they are persistent and immutable ( http://clojure.org/sequences ) So there's simply no need to have a copy function for sequences (or for any other clojure data structure). HTH, -- Laurent On 13

Is 'mapcat' name that logic ?

2008-12-13 Thread lpetit
Hello, I wanted to know if I was alone thinking that 'mapcat' should better have been named 'catmap' ? When reading code, this looks more natural because it resembles the functional composition of the 2 functions : (cat (map ...)) I know this is an inheritence from older lisp dialects, but

Re: Running out of memory when using filter?

2008-12-13 Thread Rich Hickey
On Dec 13, 2008, at 2:18 AM, Mark Engelberg wrote: On Fri, Dec 12, 2008 at 9:28 PM, Rich Hickey richhic...@gmail.com wrote: I think it's very important not to conflate different notions of sequences. Clojure's model a very specific abstraction, the Lisp list, originally implemented

Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread Randall R Schulz
On Saturday 13 December 2008 00:10, Meikel Brandmeyer wrote: Hi Randall, ... For your problem with the ruby-enabled vim: at least debian has a vim-ruby package, IIRC. So maybe Suse has this also. I installed a couple of new packages on my 10.3 box and now vim --version reports +ruby, so

Re: Functional programming newbie question

2008-12-13 Thread levand
Right... I realize there is absolutely no need to actually do this, it was more of an exercise in understanding ways to iterate over seqs. For example, I might want to do something else than a straight copy. Thanks for the replies... On Dec 13, 8:12 am, lpetit laurent.pe...@gmail.com wrote:

newbie question on true?

2008-12-13 Thread wubbie
Hello, While reading the book, I came across the phrase true? tests whether a value is actually true, not whether the value evaluates to true in a boolean context. The only thing that is true? is true: (true? true) - true (true? foo) - false Be careful with predicates ... My question is what's

Re: Functional programming newbie question

2008-12-13 Thread Rich Hickey
On Dec 12, 9:51 pm, levand luke.vanderh...@gmail.com wrote: So, I'm trying to understand functional programming, particularly as it relates to the seq abstraction, and I'm hitting a slight difficulty as I'm playing around - something that seems as if it ought to be simple, is not. I'm

Re: jEdit Mode for Clojure

2008-12-13 Thread David Moss
I've had a really quick look at your mode, it looks good, and I like the regularity in keyword highlighting. I'm going to have a proper look sometime later on the weekend and will get back to you when I have done. Kind Regards, David. 2008/12/12 Daniel Spiewak djspie...@gmail.com Sounds

Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread Meikel Brandmeyer
Hi, Am 13.12.2008 um 15:07 schrieb Randall R Schulz: I installed a couple of new packages on my 10.3 box and now vim --version reports +ruby, so I guess I can at least give it a try there (that's not my primary box, though it is the faster one). Unfortunately, vim by itself cannot do, what I

performance question

2008-12-13 Thread Dmitri
I wrote a simple word counter described here http://ptrace.fefe.de/wp/ it reads stdin and counts the occurrences of words, however I notice that it runs significantly slower than the java version in the link. I was wondering why there is such a dramatic difference. The approach I took was to

Re: Functional programming newbie question

2008-12-13 Thread ivant
On Dec 13, 4:11 pm, levand luke.vanderh...@gmail.com wrote: Right... I realize there is absolutely no need to actually do this, it was more of an exercise in understanding ways to iterate over seqs. For example, I might want to do something else than a straight copy. map is a good way to

Re: Bug in read-line?

2008-12-13 Thread Michel Salim
On Dec 13, 4:26 am, Michel Salim michel.syl...@gmail.com wrote: Using up-to-date clojure and swank-clojure, I've not been able to use read-line: - In Emacs (with Slime / swank-clojure), (read-line) never stops consuming inputs - Running clojure directly from a terminal console,

Re: performance question

2008-12-13 Thread Michel Salim
On Dec 13, 10:41 am, Dmitri dmitri.sotni...@gmail.com wrote: I wrote a simple word counter described herehttp://ptrace.fefe.de/wp/ it reads stdin and counts the occurrences of words, however I notice that it runs significantly slower than the java version in the link. I was wondering why

Re: Is 'mapcat' name that logic ?

2008-12-13 Thread Michel Salim
On Dec 13, 8:28 am, lpetit laurent.pe...@gmail.com wrote: Hello, I wanted to know if I was alone thinking that 'mapcat' should better have been named 'catmap' ? When reading code, this looks more natural because it resembles the functional composition of the 2 functions : (cat (map ...))

Re: newbie question on true?

2008-12-13 Thread Michel Salim
On Dec 13, 9:27 am, wubbie sunj...@gmail.com wrote: My question is what's the usage for ture?. I don't see a meaningful example on usage of true? At the very least, when you have to interface with Java? Also, your code might use true as a special value -- say as values inside a key to

Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread Brian Doyle
I'm sure I'm doing something stupid but I can't start up gorilla. Exception in thread main java.lang.NoClassDefFoundError: de/kotka/gorilla Caused by: java.lang.ClassNotFoundException: de.kotka.gorilla at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at

Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread Meikel Brandmeyer
Hi, Am 13.12.2008 um 17:17 schrieb Brian Doyle: Here is my script: java -cp ~/share/clojure.jar:~/share/clojure-contrib.jar:~/share/ gorilla.jar de.kotka.gorilla I can reproduce the issue. The ~ is a shellish feature from Unix. It is only expanded at the start of a word. So the first ~ in

Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread J. McConnell
On Sat, Dec 13, 2008 at 11:17 AM, Brian Doyle brianpdo...@gmail.com wrote: I'm sure I'm doing something stupid but I can't start up gorilla. Exception in thread main java.lang.NoClassDefFoundError: de/kotka/gorilla Caused by: java.lang.ClassNotFoundException: de.kotka.gorilla at

Re: The return of the monads: lessons learned about macros

2008-12-13 Thread jim
Konrad, I got your code to work by doing the following: Replaced with-monad with: (defmacro with-monad [name exprs] (let [bind-sym 'm-bind result-sym 'm-result zero-sym 'm-zero plus-sym 'm-plus] `(let [~bind-sym (:m-bind ~name) ~result-sym (:m-result

Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread Randall R Schulz
On Saturday 13 December 2008 08:17, Brian Doyle wrote: I'm sure I'm doing something stupid but I can't start up gorilla. ... Here is my script: java -cp ~/share/clojure.jar:~/share/clojure-contrib.jar:~/share/gorilla.jar de.kotka.gorilla Tildes don't expand anywhere but at the beginning

Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread Brian Doyle
Thanks Meikel, removing the ~'s worked. Oh and thanks for vimclojure and gorilla! On Sat, Dec 13, 2008 at 9:28 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 13.12.2008 um 17:17 schrieb Brian Doyle: Here is my script: java -cp

Re: performance question

2008-12-13 Thread Jeremy Dunck
On Dec 13, 9:41 am, Dmitri dmitri.sotni...@gmail.com wrote: ... The slowdown seems to occur in the inc-count function, where it updates the map using the assoc. Is this not a proper way to approach this in clojure? (recur (time (inc-count words head)) tail You're pretty

Re: performance question

2008-12-13 Thread Dmitri
I added the time call later on to find what was taking up the cycles, I also checked the reverse, it's impact is minimal, the print-words part of the program runs fast, but the read-words takes the majority of the time. On Dec 13, 12:38 pm, Jeremy Dunck jdu...@gmail.com wrote: On Dec 13, 9:41 

Re: performance question

2008-12-13 Thread Dmitri
thanks for pointing this out, and I absolutely appreciate the example. I'm still new to functional approach and I always like to see how things are done properly. On Dec 13, 1:15 pm, Chouser chou...@gmail.com wrote: On Sat, Dec 13, 2008 at 10:41 AM, Dmitri dmitri.sotni...@gmail.com wrote: I

Re: Bug in read-line?

2008-12-13 Thread Stephen C. Gilardi
I'm looking at the terminal case. It's the difference between running clojure.lang.Repl and clojure.main (which runs a repl by default). The reading done by the latter is intended to be identical to the reading done by the former but isn't in the case of read-line. If anyone sees the fix

Re: Is 'mapcat' name that logic ?

2008-12-13 Thread lpetit
On 13 déc, 17:03, Michel Salim michel.syl...@gmail.com wrote: On Dec 13, 8:28 am, lpetit laurent.pe...@gmail.com wrote: Hello, I wanted to know if I was alone thinking that 'mapcat' should better have been named 'catmap' ? When reading code, this looks more natural because it resembles

python style triple-double-quotes

2008-12-13 Thread Dan Larkin
Fellow clojurecrats, I'm here to ask for python style triple-double-quotes syntax in clojure. For those unfamiliar they're documented here: http://docs.python.org/reference/lexical_analysis.html#strings This is also a nice summary:

Re: The return of the monads: lessons learned about macros

2008-12-13 Thread jim
Konrad, I've looked over your monad code and I like it, FWIW. The macro programming will twist your mind if you don't have experience writing Lisp style macros, but the resulting syntax seems pretty clean. I would make some minor changes in two places. I would write with- monad as: (defmacro

Re: Safe to delete namespace dirs in clojure-contrib?

2008-12-13 Thread Stuart Sierra
On Dec 12, 2008, at 3:24 PM, Stuart Sierra wrote: It's been a month since Clojure rev. 1094 introduced the namespace-is- file change.  Are people still using releases that require the old contrib directories, or can we safely delete them? They're gone now as of SVN rev. 299. -Stuart Sierra

Re: import doesn't work when jar was loaded with add-classpath ?

2008-12-13 Thread Eric Sessoms
Did you ever get this resolved? I just had the same thing start happening to me today, after not experiencing any problems with it as recently as yesterday. (What changed? I tried to install swank. Nuking swank did not fix the problem, tho.) Step by step: (add-classpath ...) ; seems to work,

Re: Functional programming newbie question

2008-12-13 Thread levand
Really? I get: (last (copy-seq (range 10))) - 9 I'm running inside of VirtualBox assigned very little memory. Maybe that's why? I'll run some more tests. I know I have been able to get up to 3000 levels of recursion without a stack overflow, once, at another time. In any case, it's

Re: Functional programming newbie question

2008-12-13 Thread Randall R Schulz
On Saturday 13 December 2008 14:29, levand wrote: ... Calling reverse when done is still O(N) Really? Maybe my grasp of big-O notation is faulty, but isn't the recursive function itself O(n), and then a reversal another O(n) operation on top of that, leading to two complete traversals of

Re: Functional programming newbie question

2008-12-13 Thread Randall R Schulz
On Saturday 13 December 2008 15:35, Randall R Schulz wrote: ... Any algorithm that requires to O(n) steps is itself O(n). And by that I meant ...two O(n) steps..., of course. The big-O concept is roughly equality up to a constant factor. Randall Schulz

Patch: Detect overflow in IntegerOps.Negate

2008-12-13 Thread Olov Lassus
Hi, thanks for Clojure! Here's my first contribution (CA filled out and will arrive next week): Negating Integer.MIN_VALUE overflows but should return a BigInteger. It also affects binary subtraction since Clojure implements it using negation and addition. The overflow occurs silently

Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread Drew Olson
On Dec 13, 2008, at 2:10 AM, Meikel Brandmeyer wrote: Hi Randall, Am 12.12.2008 um 23:29 schrieb Randall R Schulz: I guess what you should say at least is that it requires Ruby and the Vim Ruby module / extension / whatever. Unfortunately, neither of the systems I use have that in their

Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread Randall R Schulz
On Saturday 13 December 2008 17:19, Drew Olson wrote: ... You can also compile vim from source with the +ruby flag Yes, of course, but that's a bridge too far. - Drew RRS --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: python style triple-double-quotes

2008-12-13 Thread Cosmin Stejerean
On Sat, Dec 13, 2008 at 7:06 PM, Dan Larkin d...@danlarkin.org wrote: Yes, I'd like the feature because it's a pain in the neck to go through and escape strings when I know there's a better way. Also sometimes it doesn't feel right to escape strings... for instance in function doc strings

Re: Updated 'show' and 'source'

2008-12-13 Thread Mark Volkmann
On Sat, Dec 13, 2008 at 6:39 PM, Chouser chou...@gmail.com wrote: On Sat, Dec 13, 2008 at 4:46 PM, Mark Volkmann r.mark.volkm...@gmail.com wrote: I just updated to the latest version of clojure-contrib. show works for me, but source doesn't. Here's what I did. (require

Problem with XML attributes and HTML entities

2008-12-13 Thread Wayne R
I've got an issue where the clojure.xml/parse and /emit functions are not symmetric with respect to how attributes are read and written. The parser decodes HTML entities (e.g. amp; - ) however the emitter does not re-encode them: user (require ['clojure.xml :as 'xml]) nil user (xml/emit

Re: python style triple-double-quotes

2008-12-13 Thread Martin DeMello
On Dec 14, 6:06 am, Dan Larkin d...@danlarkin.org wrote: Yes, I'd like the feature because it's a pain in the neck to go   through and escape strings when I know there's a better way. For escaping strings, I prefer ruby's solution, which is to have reader support for arbitrary delimiters,

Re: DISCUSS: replace (rand)

2008-12-13 Thread Mark H.
So I'm going to stop pretending like I'm an expert and actually post some Clojure code. Be constructively critical 'cause I'm a n00b in that regard ;-) This is a pseudorandom number generator for the Gaussian (0,1) distribution. (defn next-gaussrand-state [current- state] ^{:doc Given the