Re: The Joy of Closure

2011-02-07 Thread Ken Wesson
On Tue, Feb 8, 2011 at 1:46 AM, Sean Corfield wrote: > On Mon, Feb 7, 2011 at 10:01 PM, Bill Robertson > wrote: >>> "Programming Clojure" is also a good book, but it is now >>> somewhat dated as to what is happening in the language. >> I am reading the book now, and I would like to know if there

Re: Help writing a simple destructuring function.

2011-02-07 Thread Ken Wesson
On Tue, Feb 8, 2011 at 12:31 AM, CuppoJava wrote: > Thanks for the reply Ken. > > "While the macro is executing "body" will be bound to an > s-expression (basically, source code parsed to an AST but no further; > source code as processed by the reader). " > > This is the part where it falls apart.

Re: The Joy of Closure

2011-02-07 Thread Sean Corfield
On Mon, Feb 7, 2011 at 10:01 PM, Bill Robertson wrote: >> "Programming Clojure" is also a good book, but it is now >> somewhat dated as to what is happening in the language. > I am reading the book now, and I would like to know if there are any > sections that might be superseded by newer language

Re: Records implementing IFn

2011-02-07 Thread Alex Osborne
Mark Fredrickson writes: > Is the following behavior correct or a bug: > > user> (defrecord Example [data] clojure.lang.IFn (invoke [this] this) > (invoke [this n] (repeat n this))) > user.Example > user> (def e (Example. "I am e")) > #'user/e > user> (e 2) > (#:user.Example{:data "I am e"} #:use

Re: The Joy of Closure

2011-02-07 Thread Bill Robertson
> "Programming Clojure" is also a good book, but it is now > somewhat dated as to what is happening in the language. In what ways? I am reading the book now, and I would like to know if there are any sections that might be superseded by newer language features. -- You received this message beca

Re: clojure.contrib.condition

2011-02-07 Thread Michael Ossareh
https://github.com/technomancy/leiningen/blob/master/sample.project.clj try adding :aot [clojure.contrib.condition] to your project.clj ? On Mon, Feb 7, 2011 at 17:56, Brian Marick wrote: > The header documentation for clojure.contrib.condition says: > > Note: requires AOT compilation. >

Re: Help writing a simple destructuring function.

2011-02-07 Thread CuppoJava
Thanks for the reply Ken. "While the macro is executing "body" will be bound to an s-expression (basically, source code parsed to an AST but no further; source code as processed by the reader). " This is the part where it falls apart. "body" is actually bound to a single symbol. For example in t

Records implementing IFn

2011-02-07 Thread Mark Fredrickson
Is the following behavior correct or a bug: user> (defrecord Example [data] clojure.lang.IFn (invoke [this] this) (invoke [this n] (repeat n this))) user.Example user> (def e (Example. "I am e")) #'user/e user> e #:user.Example{:data "I am e"} user> (e 2) (#:user.Example{:data "I am e"} #:user.Exa

Re: extending protocols one method at a time...

2011-02-07 Thread Andrew Gwozdziewycz
Ooh! Good point. Thanks! On Feb 7, 2011 6:56 PM, "Meikel Brandmeyer" wrote: Hi, Am 07.02.2011 um 23:53 schrieb Andrew Gwozdziewycz: > Though, it doesn't return (satisfies? Foo String) correctly, but, I'll > either figure that out l... satisfies? is about instances. Sincerely Meikel -- You

Re: Help writing a simple destructuring function.

2011-02-07 Thread Ken Wesson
On Mon, Feb 7, 2011 at 10:06 PM, CuppoJava wrote: > I've thought about that actually. And it wouldn't work. > > So (defn destructure [form value] >       ...magic...) > > (defmacro let [forms body] >  `(let* ~(vec (destructure forms body))  <- at this point, "body" is > not known yet. It's just a

Re: Lazy seq from input

2011-02-07 Thread Ken Wesson
On Mon, Feb 7, 2011 at 10:18 PM, Benny Tsai wrote: > The blip.tv video of Tom Faulhaber's "Lisp, Functional Programming, > and the State of Flow" talk from Clojure Conj showed me 'fill-queue', > which seems like a good fit here. > > 'fill-queue' is a way to turn input from any source into a lazy >

Re: Help writing a simple destructuring function.

2011-02-07 Thread David Nolen
On Mon, Feb 7, 2011 at 10:06 PM, CuppoJava wrote: > I've thought about that actually. And it wouldn't work. > > So (defn destructure [form value] >...magic...) > > (defmacro let [forms body] > `(let* ~(vec (destructure forms body)) <- at this point, "body" is > not known yet. It's just

Re: Lazy seq from input

2011-02-07 Thread Benny Tsai
The blip.tv video of Tom Faulhaber's "Lisp, Functional Programming, and the State of Flow" talk from Clojure Conj showed me 'fill-queue', which seems like a good fit here. 'fill-queue' is a way to turn input from any source into a lazy sequence. You give it a one-arg function, 'filler-func', whic

Re: Help writing a simple destructuring function.

2011-02-07 Thread CuppoJava
I've thought about that actually. And it wouldn't work. So (defn destructure [form value] ...magic...) (defmacro let [forms body] `(let* ~(vec (destructure forms body)) <- at this point, "body" is not known yet. It's just a symbol. ~@body) This approach won't work because "body" i

Re: Lazy seq from input

2011-02-07 Thread Ken Wesson
On Mon, Feb 7, 2011 at 9:16 PM, Andreas Kostler wrote: > Thank's Ken, that's doing what I want. However, being the noob I am, I don't > quite understand what's going on. > Do you mind elaborating a little bit on the functions? Your help is greatly > appreciated :) You're welcome. Take-until is

Re: Lazy seq from input

2011-02-07 Thread Andreas Kostler
Thank's Ken, that's doing what I want. However, being the noob I am, I don't quite understand what's going on. Do you mind elaborating a little bit on the functions? Your help is greatly appreciated :) Cheers Andreas On 08/02/2011, at 12:00 PM, Ken Wesson wrote: > On Mon, Feb 7, 2011 at 8:09 PM

Re: Lazy seq from input

2011-02-07 Thread Ken Wesson
On Mon, Feb 7, 2011 at 8:09 PM, Andreas Kostler wrote: > Hi all, > Is it possible to read from a lazy input sequence? I have a telnet > connection using commons.telnet and I want to do something like: > (def telnet (TelnetClient.)) > (def in (. telnet getInputStream)) > > ; How do I do this? > (de

Re: Anyone want to take a crack at making the fasta shootout program faster?

2011-02-07 Thread Bill James
On Feb 7, 3:47 pm, Andy Fingerhut wrote: > (defn find-index [f coll] >    (loop [i (int 0) >           s (seq coll)] >      (if (f (first s)) >        i >        (recur (unchecked-inc i) (rest s) > I didn't realize how slow my version of this was. This change alone shaves off about half a s

clojure.contrib.condition

2011-02-07 Thread Brian Marick
The header documentation for clojure.contrib.condition says: Note: requires AOT compilation. What do I therefore do differently? How should my program text change? Conditions seem to work in the REPL, but not in my program. I don't know if that's due to the mysteries of AOT compiling or so

Lazy seq from input

2011-02-07 Thread Andreas Kostler
Hi all, Is it possible to read from a lazy input sequence? I have a telnet connection using commons.telnet and I want to do something like: (def telnet (TelnetClient.)) (def in (. telnet getInputStream)) ; How do I do this? (def read-until ; read from a lazy input sequence UNTIL prompt is matched

Re: Help writing a simple destructuring function.

2011-02-07 Thread Alan
(defn destructure [binding-form] ...magic...) (defmacro let [forms body] `(let* ~(vec (destructure forms)) ~@body)) On Feb 7, 1:46 pm, CuppoJava wrote: > Actually that would be fine as a solution as well. I'm stumped as to > how to avoid repeating the same thing twice (once in function

Re: extending protocols one method at a time...

2011-02-07 Thread Meikel Brandmeyer
Hi, Am 07.02.2011 um 23:53 schrieb Andrew Gwozdziewycz: > Though, it doesn't return (satisfies? Foo String) correctly, but, I'll > either figure that out later, or ultimately not care. satisfies? is about instances. Sincerely Meikel -- You received this message because you are subscribed to t

Re: extending protocols one method at a time...

2011-02-07 Thread Andrew Gwozdziewycz
Playing around a bit more: (defprotocol Foo (bar [_] "do bar") (baz [_] "do baz")) (defmacro defp [name arglist proto & bodies] (let [pairs (partition 2 bodies) protocol (resolve proto) namekw (keyword name) impls (reduce (fn [accum [t body]]

Re: ANN: Textmash - another IDE for Clojure

2011-02-07 Thread Olek
Hi, Yes, I would like to replace Java version with Clojure. For the shorter startup time, I will try to do some threading (for menu building and configuration reading) and compile clj files of boostrap module (not existing yet) to .class. If the problem would lay in clojure itself then I hope that

[ANN]: clojuresque 1.4.0 released

2011-02-07 Thread Meikel Brandmeyer
Dear fellow clojurians, I'd like to announce release 1.4 of the clojuresque plugin for gradle. It makes gradle clojure aware and helps with compiling and testing clojure code in gradle-powered projects. Changes to 1.3: * compatible with gradle 0.9 * leiningen style deps task * ueberjar is renam

Re: extending protocols one method at a time...

2011-02-07 Thread Andrew Gwozdziewycz
On Mon, Feb 7, 2011 at 3:30 PM, Ken Wesson wrote: > On Mon, Feb 7, 2011 at 2:49 PM, Andrew Gwozdziewycz wrote: >> On Mon, Feb 7, 2011 at 2:16 PM, Ken Wesson wrote: >>> Can't you just use extend-protocol to group your protocol >>> implementations for each record type in one place? >> >> That cert

Re: Anyone want to take a crack at making the fasta shootout program faster?

2011-02-07 Thread Andy Fingerhut
On Feb 7, 2011, at 12:37 PM, Bill James wrote: Since this program eliminates so much of the work, it's disappointing that there wasn't more of a speedup. Can you (or anyone) speed it up even further? I spent some time doing some small tweaks. On one machine I have, your version runs in as l

Re: Help writing a simple destructuring function.

2011-02-07 Thread CuppoJava
Actually that would be fine as a solution as well. I'm stumped as to how to avoid repeating the same thing twice (once in function world and once in macro world). ie. Let's assume that we have this destructuring function. How do we use that do program a destructuring let macro? -Patrick On Feb

Re: Anyone want to take a crack at making the fasta shootout program faster?

2011-02-07 Thread Bill James
Since this program eliminates so much of the work, it's disappointing that there wasn't more of a speedup. Can you (or anyone) speed it up even further? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goog

Re: Help writing a simple destructuring function.

2011-02-07 Thread Ken Wesson
On Mon, Feb 7, 2011 at 3:01 PM, Meikel Brandmeyer wrote: > Hi, > > Am 07.02.2011 um 20:51 schrieb CuppoJava: > >> Thanks for your answer Meikel. >> >> Your answer isn't that ugly. It's very similar to what I have as >> well. >> >> I would like to know if you think it's possible to re-use "let" to

Re: extending protocols one method at a time...

2011-02-07 Thread Ken Wesson
On Mon, Feb 7, 2011 at 2:49 PM, Andrew Gwozdziewycz wrote: > On Mon, Feb 7, 2011 at 2:16 PM, Ken Wesson wrote: >> Can't you just use extend-protocol to group your protocol >> implementations for each record type in one place? > > That certainly works, but it's really not much different than: > >

Re: Help writing a simple destructuring function.

2011-02-07 Thread Meikel Brandmeyer
Hi, Am 07.02.2011 um 20:51 schrieb CuppoJava: > Thanks for your answer Meikel. > > Your answer isn't that ugly. It's very similar to what I have as > well. > > I would like to know if you think it's possible to re-use "let" to do > this. I feel like I'm re-inventing the wheel somewhat. I don't

Re: extending protocols one method at a time...

2011-02-07 Thread Andrew Gwozdziewycz
On Mon, Feb 7, 2011 at 2:16 PM, Ken Wesson wrote: > Can't you just use extend-protocol to group your protocol > implementations for each record type in one place? That certainly works, but it's really not much different than: (defrecord Bar [x y] Foo (bar [_] ...) (baz [_] ...) whi

Re: Help writing a simple destructuring function.

2011-02-07 Thread CuppoJava
Thanks for your answer Meikel. Your answer isn't that ugly. It's very similar to what I have as well. I would like to know if you think it's possible to re-use "let" to do this. I feel like I'm re-inventing the wheel somewhat. -Patrick On Feb 7, 2:44 pm, Meikel Brandmeyer wrote: > Hi, > > Am

Re: Help writing a simple destructuring function.

2011-02-07 Thread Meikel Brandmeyer
Hi, Am 07.02.2011 um 20:26 schrieb CuppoJava: > I was wondering whether the "destructure" function can be written > using the existing "let" form. Thanks for your help. Ah ok. Nevermind. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" g

Re: Help writing a simple destructuring function.

2011-02-07 Thread Meikel Brandmeyer
Hi, Am 07.02.2011 um 18:20 schrieb Justin Kramer: > Checking out clojure.core/destructure and clojure.core/let might be > helpful. > > Here's a macro I hacked together. It doesn't work with :keys, :as, > or :or. I take no responsibility if you use it for anything real. But > maybe it will provid

Re: Help writing a simple destructuring function.

2011-02-07 Thread CuppoJava
Sorry, I wasn't being very clear about my needs. I need this function to run at *run-time*. So the following: (def values [1 2 [3 4 5 6 7 8]]) (def form '(a b (c d & e))) (destructure form values) Should return: {:a 1 :b 2 :c 3 :d 4 :e [5 6 7 8]} I was wondering whether the "destructure" functi

Re: extending protocols one method at a time...

2011-02-07 Thread Ken Wesson
Can't you just use extend-protocol to group your protocol implementations for each record type in one place? -- 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

Re: Help writing a simple destructuring function.

2011-02-07 Thread Fogus
I have a library called Evalive (http://github.com/fogus/evalive) that could help. Specifically I added a macro named `destro` that will do _mostly_ what you want. Basically, it looks like the following: (destro [a b [c d & e]] [1 2 [3 4 5 6 7 8]]) Which returns: {vec__2183 [1 2 [3 4 5 6 7 8]

[ANN] http.async.client v0.2.2 released

2011-02-07 Thread Hubert Iwaniuk
Hi All, Just released v0.2.2 of HTTP Asynchronous Client. Featuring following changelog http://bit.ly/hc9dxt - get-encoding helper works w/o Content-Type header - upgrade async-http-client to v1.5.0 - exposed more configuration options - zero byte copy mode - allow providing your own poll - allo

extending protocols one method at a time...

2011-02-07 Thread Andrew Gwozdziewycz
Hey all, So, for a random project, I found myself using a single protocol extended to a bunch of record types. I did this using the support in `defrecord` itself, but what I dislike about it is that the definitions for each method of the protocol are spread out amongst multiple sections of code.

Re: Which branch of clojure-hadoop to use?

2011-02-07 Thread Benny Tsai
Thank you, Alex, for the response and your work on the code. And thank you for getting the ball rolling on coordinating clojure-hadoop dev work as well. On Feb 6, 3:58 am, Alex Ott wrote: > Hello > > I'm not working actively on clojure-hadoop, so maybe eslick's and clizzin's > forks could be mor

Re: Help writing a simple destructuring function.

2011-02-07 Thread Justin Kramer
Checking out clojure.core/destructure and clojure.core/let might be helpful. Here's a macro I hacked together. It doesn't work with :keys, :as, or :or. I take no responsibility if you use it for anything real. But maybe it will provide you with some ideas. (defmacro destructure->map [bvec val]

Re: Anyone want to take a crack at making the fasta shootout program faster?

2011-02-07 Thread Andy Fingerhut
Nice. I get about 1/3 of the run time on the two systems I've tested on, too, including one that isn't terribly far off in hardware from the 64-bit benchmark machine used by the shootout web site. I'll contact you off list about how this gets submitted to the web site. Thanks! Andy On Feb

Help writing a simple destructuring function.

2011-02-07 Thread CuppoJava
Hello everyone, I am trying to write the following function: --- Suppose form = [1 2 [3 4 5 6 7 8]] (destructure '(a b (c d & e)) form) should return: {:a 1 :b 2 :c 3 :d 4 :e [5 6 7 8]} -

Using maven with clojure-contrib 1.3

2011-02-07 Thread MHOOO
For some reason, whenever I use one of the clojure-contrib 1.3 jars in my leiningen project file (e.g. org.clojure/contrib/logging) and then install that (using lein install) into my local repo, I get errors about the generated pom file to be invalid whenever I try to depend on the project (the pro

Re: ANN: Textmash - another IDE for Clojure

2011-02-07 Thread Laurent PETIT
2011/2/7 Shantanu Kumar : >> * Is your intent to replace eventually the java version with the >> clojure version ? If so, how do you deal with the concern of "quick >> startup time" ? > > An idea: jEdit optionally lets you start a background server during > system startup so that firing up jEdit ca