Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread Mark Engelberg
On Sun, Dec 28, 2008 at 12:49 AM, bOR_ boris.sch...@gmail.com wrote: Annoying way to start a morning :P. Thanks though for the tip on htdp.org I'm not trying to be annoying. I just don't know how valuable the answer will be to you, until you've got a better handle on recursion. The code

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread bOR_
Thanks. I understood your intentions, and it didn't hurt for me to find my own solution. (time (count (expand (first myset Elapsed time: 2426.327 msecs 403200 Timing yours it is about as fast as the flexible for version, but not as fast as the tailored for version. Perhaps I should look at

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread bOR_
Ah. The prohibitively long bit comes mainly from printing out the whole list in emacs. Counting it is only a few seconds, and not that much slower than for the fixed-length version. In computer-time it is still taking ages though. Why am I going through all of this?: I have 3 filters in the form

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread Mark Engelberg
I'm not surprised that the flexible version takes a bit more time than the one that's hardcoded to a for loop nested to 9 levels. The flexible version necessarily involves recursion, which means allocating some stack space with each call, and that's a bit of overhead. I am a bit surprised that

Re: distinct broken?

2008-12-28 Thread Christophe Grand
Mark Engelberg a écrit : So one thing I don't get is why would tristan's pow code sometimes generate a BigInteger, and sometimes a Long for the same resulting number? Good question. (pow 2 32); returns 4294967296 (BigInteger) (pow 4 16); returns 4294967296 (Long) (pow 16 8); returns

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread Mark Engelberg
I coded up a quickie iterative version for you so you can get an idea what that looks like. My timing tests indicate that this runs many times faster than even the hardcoded for loop nested to 9 levels. ; Convert to a vector, and pass off to step, which builds a lazy sequence by applying

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread Mark Engelberg
This iterative version doesn't behave properly if one of the sequences is empty. Expand should probably check for this degenerate case before passing the vector off to step. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread bOR_
On Dec 28, 12:26 pm, Mark Engelberg mark.engelb...@gmail.com wrote: This iterative version doesn't behave properly if one of the sequences is empty.  Expand should probably check for this degenerate case before passing the vector off to step. I'll take care of that Interesting. on my comp,

Re: Exercise: words frequency ranking

2008-12-28 Thread Boyd Brown
Hello. I can't seem to find 'spit'. java exception: unable to resolve symbol spit. I'm using Clojure Box rev1142. Tried using the clojure.jar from the 20081217 release of Clojure but to no avail. spit is not documented on the clojure site API page like slurp is. I can't find it in clojure

Re: Simple question using Agents.

2008-12-28 Thread Mark Volkmann
Are you sure the code below works? It doesn't work for me with the revision 1185. For me it outputs: #Agent clojure.lang.ag...@355a47 0 and stops. On Tue, Dec 23, 2008 at 12:18 PM, Stephen C. Gilardi squee...@mac.com wrote: On Dec 23, 2008, at 1:03 PM, CuppoJava wrote: (send-off my_agent

Re: Simple question using Agents.

2008-12-28 Thread Stephen C. Gilardi
On Dec 28, 2008, at 9:58 AM, Mark Volkmann wrote: Are you sure the code below works? It doesn't work for me with the revision 1185. For me it outputs: #Agent clojure.lang.ag...@355a47 0 and stops. A change to Clojure's behavior at r1158 caused my incorrect (or at least iffy) code break

Where's spit? (Was: Exercise: words frequency ranking)

2008-12-28 Thread Mibu
You're not at fault here. The documentation about loading libraries is still scarce and not very helpful yet. I too had to scramble to figure this one out. spit is in the duck-streams library in clojure.contrib. I understand it is planned to be moved to the core library, as it should. Here is

Re: A quasiquote for Clojure?

2008-12-28 Thread Meikel Brandmeyer
Hi, Am 23.12.2008 um 17:08 schrieb Rich Hickey: SVN 1184 implements this. Feedback welcome on its utility for macro writers. Many Thanks Rich! Here is a half-baked quasiquote macro ripped out of the syntax-quote reader: (defmacro quasiquote [form] (let [unquote?(fn [f] (and (seq?

Swank in Tomcat via JSP: classpath issues

2008-12-28 Thread Greg Harman
I tried creating a JSP to let Slime connect to a REPL running in Tomcat, as was posted here: http://groups.google.com/group/clojure/browse_thread/thread/d73efa2943179a36/dd1c84dcf658436e?lnk=gstq=jsp#dd1c84dcf658436e The JSP works in that there is an instance of swank running in Tomcat's JVM,

Efficiency and if

2008-12-28 Thread penguin2...@gmail.com
So I was wrote a function that read a InputStream into a FileOutputStream. I noticed (after my CPU fan kept turning on) that it was taking upwards of 70% of my Athlon 64 X2 +5000! Heres that version: (defn read-bytes-to-file [istream filename] (with-open [ostream (new FileOutputStream

Fibonacci sequence

2008-12-28 Thread Craig Marshall
Hi, I'm trying to learn lisp and Clojure and so I'm trying some excercises suggested here on the group a while ago. I'm not doing too well, I had to cheat on excercise one (make a series of integers) by looking at the source code to the range function, and I'm now having to ask for help with

Re: distinct broken?

2008-12-28 Thread Rich Hickey
On Dec 28, 2008, at 5:27 AM, Christophe Grand wrote: Mark Engelberg a écrit : So one thing I don't get is why would tristan's pow code sometimes generate a BigInteger, and sometimes a Long for the same resulting number? Good question. (pow 2 32); returns 4294967296 (BigInteger) (pow 4

Re: Fibonacci sequence

2008-12-28 Thread David Nolen
(defn fib-helper [a b] (fib-helper b (+ a b))) (defn fib (fib-helper 0 1)) ; This doesn't work either: (defn fib (fib- helper '(0 1))) You're missing your argument list for fib. (println (take 5 fib)) take creates a lazy list from a collection: (take n collection) Your fib does not

Re: Where's spit? (Was: Exercise: words frequency ranking)

2008-12-28 Thread Boyd Brown
On Dec 28, 9:33 am, Mibu mibu.cloj...@gmail.com wrote: You're not at fault here. The documentation about loading libraries is still scarce and not very helpful yet. I too had to scramble to figure this one out. spit is in the duck-streams library in clojure.contrib. I understand it is

Re: Classes and Clojure reader (newbie questions)

2008-12-28 Thread TPJ
(...) This is perfectly possible, although not necessarily desirable. (ns com.example.MyClass    (:gen-class      :state state      :init init      :methods [[getMyIntField [] Integer]                [setMyIntField [Integer] Void/TYPE]])) (defn -init    [x]    [[] (ref x)]) (defn

Re: distinct broken?

2008-12-28 Thread Christophe Grand
Rich Hickey a écrit : The right thing I think is to represent as Integer and Long whenever possible, and do overflow checking (as is done in the static add(long,long) etc) rather than pre-op upconversion to next size. This would require the addition of a LongOps etc. I see. I've

Fwd: [jvm-l] Kawa Scheme on Android

2008-12-28 Thread Randall R Schulz
Howdy, Folks, The gauntlet has been thrown down: -- Forwarded Message -- Subject: [jvm-l] Kawa Scheme on Android Date: Sunday 28 December 2008 14:43 From: Per Bothner p...@bothner.com To: jvm-langua...@googlegroups.com I managed to get a hello-world-style program written in

Re: Some code review for clj-record?

2008-12-28 Thread Brian Doyle
Having used Rails myself I wanted to check this out and play with it. I'm having some trouble just loading the clj_record/core.clj file though: 1:1 user= (load-file clj_record/core.clj) java.lang.Exception: Unable to resolve symbol: db in this context (core.clj:19) I'm sure it's something I'm

Re: why two list comprehensions are different?

2008-12-28 Thread Michael Wood
Hi On Sat, Dec 27, 2008 at 11:40 PM, wubbie sunj...@gmail.com wrote: I didn't get the syntax error at all: Yes, but I think maybe there is a bug in Clojure that causes the first case to work when it should give a syntax error. If it is not a bug I do not understand why it ignores the

Re: Efficiency and if

2008-12-28 Thread Timothy Pratley
(neg? b-read) (pos? b-read) are not precisely opposites. user= (pos? 0) false user= (neg? 0) false As you can see, the edge condition 0 is treated differently in you two implementations. This is the real difference, not the if. Blocking streams that return 0 indicate that the stream is

Re: Swank in Tomcat via JSP: classpath issues

2008-12-28 Thread Michael Wood
On Sun, Dec 28, 2008 at 8:11 AM, Greg Harman ghar...@gmail.com wrote: I tried creating a JSP to let Slime connect to a REPL running in Tomcat, as was posted here: http://groups.google.com/group/clojure/browse_thread/thread/d73efa2943179a36/dd1c84dcf658436e?lnk=gstq=jsp#dd1c84dcf658436e The

clojure slime/swank mode problem -- still NewBie

2008-12-28 Thread wubbie
Hi all, I've been using command line Repl for a while and want to move to slime/emacs so I followed instructions in wiki and got errors in emacs: I was able to load ants.clj in upper panel. On the bottom panel, alt -x slime give me the following errors: (require 'swank.swank)

Re: take 1 element from each coll, make all possible strings?

2008-12-28 Thread Timothy Pratley
If you aren't interested in the permutations themselves, just the number of them (if I read you right) The only way I could think up to know exactly what fraction of the optimum (2x 5%: remember the diploidi)) a set of combined filters can present is by expanding these filters into a set

Re: Fibonacci sequence

2008-12-28 Thread Michael Wood
On Sun, Dec 28, 2008 at 6:01 PM, Craig Marshall cra...@gmail.com wrote: Hi, I'm trying to learn lisp and Clojure and so I'm trying some excercises suggested here on the group a while ago. I'm not doing too well, I had to cheat on excercise one (make a series of integers) by looking at the

Re: clojure slime/swank mode problem -- still NewBie

2008-12-28 Thread wubbie
Also my .emacs is pasted here: Just copy from wiki... ;; clojure mode (add-to-list 'load-path /usr/local/clojure-mode) (require 'clojure-auto) ;; Slime (add-to-list 'load-path /usr/local/slime) (require 'slime) (slime-setup) ;; clojure swank (setq swank-clojure-jar-path

making code readable

2008-12-28 Thread Mark Volkmann
This is related to the thread titled Proxying in Clojure. I've spent a lot of time studying the code in this snake example and have some observations I'd like to share. First off, obviously I care about the future of Clojure or I wouldn't have spent the last six weeks or so trying to learn it.

Re: making code readable

2008-12-28 Thread Rich Hickey
On Dec 28, 8:13 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote: This is related to the thread titled Proxying in Clojure. I've spent a lot of time studying the code in this snake example and have some observations I'd like to share. First off, obviously I care about the future of

Re: making code readable

2008-12-28 Thread Mark Volkmann
On Sun, Dec 28, 2008 at 9:15 PM, Rich Hickey richhic...@gmail.com wrote: On Dec 28, 8:13 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote: This is related to the thread titled Proxying in Clojure. I've spent a lot of time studying the code in this snake example and have some observations

Re: why two list comprehensions are different?

2008-12-28 Thread David Nolen
Yes, but I think maybe there is a bug in Clojure that causes the first case to work when it should give a syntax error. If it is not a bug I do not understand why it ignores the expression. It's not a bug in Clojure because Clojure doesn't really have syntax in the way that you seem to be

Parallel words frequency ranking

2008-12-28 Thread Piotr 'Qertoip' Włodarek
Following my recent adventure with words ranking, here's the parallel version: (use 'clojure.contrib.duck-streams) (defn top-words-core [s] (reduce #(assoc %1 %2 (inc (%1 %2 0))) {} (re-seq #\w+ (.toLowerCase s (defn format-words [words] (apply

Re: Swank in Tomcat via JSP: classpath issues

2008-12-28 Thread Greg Harman
Thanks for that - I'm all up to date now. The bad news is that it didn't seem to affect my problem at all. On Dec 28, 6:58 pm, Michael Wood esiot...@gmail.com wrote: The current version of Clojure is 1185.  Clojure was recently moved to Google Code:

Re: Some code review for clj-record?

2008-12-28 Thread John D. Hume
The db configuration isn't reasonable at the moment. You can run clj_record/test/main.clj as a script but not load it from the REPL. Let me see if I can get it to work both ways and push an update. On Sun, Dec 28, 2008 at 6:28 PM, Brian Doyle brianpdo...@gmail.com wrote: Having used Rails

Re: Some code review for clj-record?

2008-12-28 Thread John D. Hume
Ok, please pull the latest and try again. git clone git://github.com/duelinmarkers/clj-record.git The problem was due to something I've seen a couple other messages about: When running a file as a script, it starts out in the clojure.core namespace. I was doing (def db {...}) before any (ns ...)

Re: Exercise: words frequency ranking

2008-12-28 Thread Chouser
On Sun, Dec 28, 2008 at 9:22 AM, Boyd Brown boy...@gmail.com wrote: Hello. I can't seem to find 'spit'. 'spit' is in clojure-contrib: http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/duck_streams.clj?r=325#177 It's inclusion in clojure.core is planned (search

Re: Dubious generated bytecode

2008-12-28 Thread Peter Collingbourne
On Thu, Jul 31, 2008 at 02:01:08PM -0700, Rich Hickey wrote: On Jul 31, 11:43 am, Stefan Ring stefan...@gmail.com wrote: Thanks a lot. Your change makes the CACAO verifier happy but I think you should revert it. The instruction in question is actually invokeinterface, not

Re: Dubious generated bytecode

2008-12-28 Thread Rich Hickey
On Dec 28, 10:49 pm, Peter Collingbourne pe...@pcc.me.uk wrote: On Thu, Jul 31, 2008 at 02:01:08PM -0700, Rich Hickey wrote: On Jul 31, 11:43 am, Stefan Ring stefan...@gmail.com wrote: Thanks a lot. Your change makes the CACAO verifier happy but I think you should revert it. The

Re: Modulo

2008-12-28 Thread Rich Hickey
On Dec 29, 12:44 am, Mark Engelberg mark.engelb...@gmail.com wrote: So I understand that we're supposed to discuss ideas here to try to gain mindshare which is why last week I brought up the issue with Clojure missing mod (which works differently from rem on negative numbers). So really,

Re: Parallel words frequency ranking

2008-12-28 Thread Chouser
On Sun, Dec 28, 2008 at 10:50 PM, Piotr 'Qertoip' Włodarek qert...@gmail.com wrote: Following my recent adventure with words ranking, here's the parallel version: (use 'clojure.contrib.duck-streams) Thanks for including your 'use' line -- that's so much better than leaving it implied.

Re: making code readable

2008-12-28 Thread Abhishek Reddy
Speaking for myself, as the author of the original Snake example, I had no intention of converting developers to Clojure, or of producing instructive or readable code, with that snippet. While I agree with some of your critique, I do think it is misplaced. The aim of this particular exercise was

Re: Modulo

2008-12-28 Thread Vincent Foley
I suppose then that we would also need div. Using GHCi here: Prelude (-3) `div` 2 -2 Prelude (-3) `quot` 2 -1 On Dec 22, 7:04 am, Mark Engelberg mark.engelb...@gmail.com wrote: Anyone know why there is no modulo or mod function in Clojure's core? I know there is a rem function, but that's