Re: Homoiconicity and printing functions

2009-07-09 Thread Mike
On Jul 8, 12:47 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, I'd like to second the suggestion of Richard and Daniel (in the other thread): use a file. It solves almost all problems with immediate effect. Here is my workflow for your example. I added some annotations. (as a note: I use

Re: Clojure box - loading book examples from Programming Clojure

2009-07-09 Thread Daniel
On Thu, Jul 9, 2009 at 1:56 AM, Manidumb...@gmail.com wrote: Thanks Shawn, Robert. From Robert's post, I am bit confused here. I also read that .emacs is in %appdata% folder (vista), but all I see is .emacs.d folder (which I guess is for the emacs server). I tried creating one C-x C-f

From Java to Clojure

2009-07-09 Thread Patrik Fredriksson
Hi! I started to look closer at Clojure after Rich Hickey's presentation at QCon London in March, this is my first post. I spend my days programming Java, but my journey as developer did actually start with an ML programming course many years ago. It has been great fun to re-discover the

Re: zip of docs?

2009-07-09 Thread Justin Johnson
No, same thing. If you go to clojure.wikispaces.com it redirects to clojure.org, which is hosted at wikispaces.com. On Wed, Jul 8, 2009 at 5:15 PM, Raoul Duke rao...@gmail.com wrote: It looks like anyone with Organizer rights on Clojure's wikispaces wiki should be able to export an HTML or

On laziness and with-open

2009-07-09 Thread Mike
I wanted to grab bytes out of a stream, and didn't see an analogue to reader from duck-streams, so I made my own: (defn byte-seq Returns the bytes from stream as a lazy sequence of ints. stream must implement java.io.InputStream. [#^java.io.InputStream stream] (lazy-seq (let [b (.

Re: On laziness and with-open

2009-07-09 Thread B Smith-Mannschott
On Thu, Jul 9, 2009 at 12:10, Mikecki...@gmail.com wrote: I wanted to grab bytes out of a stream, and didn't see an analogue to reader from duck-streams, so I made my own: (defn byte-seq  Returns the bytes from stream as a lazy sequence of ints.  stream must implement java.io.InputStream.

Re: From Java to Clojure

2009-07-09 Thread Sean Devlin
One question on design intent before feedback. Is your intent to have this Clojure code called by Java code later? On Jul 9, 7:31 am, Patrik Fredriksson patri...@gmail.com wrote: Hi! I started to look closer at Clojure after Rich Hickey's presentation at QCon London in March, this is my

Re: On laziness and with-open

2009-07-09 Thread Janico Greifenberg
Hi Mike, On Thu, Jul 9, 2009 at 12:10 PM, Mikecki...@gmail.com wrote: I wanted to grab bytes out of a stream, and didn't see an analogue to reader from duck-streams, so I made my own: (defn byte-seq  Returns the bytes from stream as a lazy sequence of ints.  stream must implement

Re: On laziness and with-open

2009-07-09 Thread eyeris
I ran the code you pasted here. It didn't throw an IOException for me. I am running 1.0. On Jul 9, 5:10 am, Mike cki...@gmail.com wrote: I wanted to grab bytes out of a stream, and didn't see an analogue to reader from duck-streams, so I made my own: (defn byte-seq   Returns the bytes from

Re: Clojure cheat sheet

2009-07-09 Thread tmountain
This is very cool. I will definitely be keeping a copy on my laptop as a quick reference. Thanks for putting it together. Travis On Jul 8, 5:04 am, Steve Tayon steve.ta...@googlemail.com wrote: Hello everyone, while looking around for a modern lisp, I discovered Clojure and was instantly

missing 'abstract'?

2009-07-09 Thread jon
Rich, could this be a minor omission? public class AReference implements IReference { } is not declared 'public abstract class' like ARef, AFn, APersistentMap, and the others... Cheers, Jon --~--~-~--~~~---~--~~ You received this message because you are

Re: From Java to Clojure

2009-07-09 Thread Patrik Fredriksson
The idea is to gradually, over a few steps, move from a Java implementation to a pure Clojure implementation. A this step the Clojure implementation is called by the Java JUnit-test (see complete test below). In the last step, the Java-references will be removed from the Clojure implementation

Re: Passing primitives from an inner loop to an outer loop efficiently

2009-07-09 Thread Frantisek Sodomka
Jonathan showed destructuring/indexing very nicely. Here are some timings for vector/list creation: (let [lst '(1 2 3)] (timings 1e7 (list 1 2 3) (cons 1 (cons 2 (cons 3 ( (conj (conj (conj () 3) 2) 1) (vector 1 2 3) (vec lst) (conj (conj (conj [] 1) 2) 3)))

Clojure in Clojure?

2009-07-09 Thread tmountain
I just finished watching the Bay Area Clojure Meetup video, and Rich spent a few minutes talking about the possibility of Clojure in Clojure. The prospect of having Clojure self-hosted is incredibly cool, but it brought a few questions to mind. For one, Rich mentions that it would potentially

Re: From Java to Clojure

2009-07-09 Thread Sean Devlin
Okay, since you DO call the Clojure code from Java, I like what you did very much. If you're running edge Clojure, and not 1.0, I'd recommend writing the tests in Clojure next, using the clojure.test namespace. Sean On Jul 9, 10:16 am, Patrik Fredriksson patri...@gmail.com wrote: The idea is

Re: Got a Clojure library?

2009-07-09 Thread stephaner
Name: com.konato.ode URL: http://www.konato.com/2009/07/08/com-konato-ode/ Author: Stephane Rousseau Categories: Scientific computing, Simulation, ODE License: EPL Dependencies: clojure.contrib.test-is for unit testing Description: This is an ordinary differentials

Re: Idea for contrib.def: defmemo

2009-07-09 Thread Chouser
On Jul 8, 11:53 pm, samppi rbysam...@gmail.com wrote: In clojure.contrib.def, I'd love to have a defmemo macro that acts just like defn, only with memoize. I'm planning to change a lot of functions to use memoize, and I'm not looking forward to changing nice, clean defns with docstrings to

Re: Idea for contrib.def: defmemo

2009-07-09 Thread samppi
Excellent. This will be a lifesaver—thanks a lot. On Jul 9, 8:21 am, Chouser chou...@gmail.com wrote: On Jul 8, 11:53 pm, samppi rbysam...@gmail.com wrote: In clojure.contrib.def, I'd love to have a defmemo macro that acts just like defn, only with memoize. I'm planning to change a lot of

Re: Clojure in Clojure?

2009-07-09 Thread Paul Mooser
Since clojure is a compiled language, and is going to just end up generating java bytecodes, I wouldn't expect it to be particularly slower if it was written in itself. Maybe that's naive ? --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: Clojure in Clojure?

2009-07-09 Thread Daniel Lyons
On Jul 9, 2009, at 10:07 AM, Paul Mooser wrote: Since clojure is a compiled language, and is going to just end up generating java bytecodes, I wouldn't expect it to be particularly slower if it was written in itself. Maybe that's naive ? It's not naive. This is called self-hosting and it

Re: Clojure in Clojure?

2009-07-09 Thread tmountain
To be safe one often retains a stub compiler for some subset of the language written in another language, and then implements the rest of the language in the stub version. This makes a lot of sense. So basically, a subset of Clojure could be ported to whatever language you'd want to target,

Re: Got a Clojure library?

2009-07-09 Thread Meikel Brandmeyer
Name: Jazz URL: http://kotka.de/projects/clojure/jazz.html Author: Meikel Brandmeyer Categories: GUI License: MIT Dependencies: c.c.def, c.c.except, c.c.swing-utils, JGoodies Forms Description: Jazz eases the creation of GUI forms by virtue of the JGoodies Forms library. One specifies the desired

Re: From Java to Clojure

2009-07-09 Thread Chouser
On Thu, Jul 9, 2009 at 7:31 AM, Patrik Fredrikssonpatri...@gmail.com wrote: My shot at a Clojure implementation, with inspiration from a previous post in this group on a similar problem: (ns step3.pnehm.clojure-orderer  (:gen-class    :name step3.pnehm.ClojureOrderer    :implements

Re: On laziness and with-open

2009-07-09 Thread B Smith-Mannschott
On Thu, Jul 9, 2009 at 16:43, eyerisdrewpvo...@gmail.com wrote: I ran the code you pasted here. It didn't throw an IOException for me. I am running 1.0. I suspect that You're Doing it Wrong. You'll see the exception only if you actually try to evaluate the lazy sequence returned by byte-seq.

Re: Homoiconicity and printing functions

2009-07-09 Thread Richard Newman
If you want to be able to query a function for its source code later on, that's tougher. You'll need to make a macro that wraps defn and assigns a copy of the body form to a metadata tag on the function's name. I'm resurrecting this thread because I'm actually hitting this problem

Re: On laziness and with-open

2009-07-09 Thread Sean Devlin
That pages says the scopes system is already designed. To you have any preliminary design docs posted somewhere? On Jul 9, 2:59 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: On Jul 9, 6:10 am, Mike cki...@gmail.com wrote: Is there a pattern out there in Clojure for handling laziness

Re: Homoiconicity and printing functions

2009-07-09 Thread Chouser
On Thu, Jul 9, 2009 at 4:19 PM, Richard Newmanholyg...@gmail.com wrote: Is there any particular reason why Fn doesn't implement IMeta? Actually, it does. user= (instance? clojure.lang.IMeta (fn [])) true What it doesn't support is changing the metadata after creation: user= (with-meta (fn

Re: Homoiconicity and printing functions

2009-07-09 Thread Richard Newman
Actually, it does. Ah, that explains the UnsupportedOperationException :) user= (instance? clojure.lang.IMeta (fn [])) true What it doesn't support is changing the metadata after creation: user= (with-meta (fn []) {:foo bar}) java.lang.UnsupportedOperationException (NO_SOURCE_FILE:0)

Re: Homoiconicity and printing functions

2009-07-09 Thread Richard Newman
That was easy! user= (defmacro metafn [meta args body] `(proxy [clojure.lang.AFn] [~meta] (invoke ~args ~...@body))) #'user/metafn user= (metafn {:foo :bar} [a b c] (println a) (+ a b c)) #AFn clojure.proxy.clojure.lang@77309516 user= (*1 1 2 3) 1 6 user= (meta (metafn {:foo :bar} [a

pattern matching

2009-07-09 Thread Raoul Duke
hi, i see it has been discussed before, and that there are lots of options. :-) to restrict it a bit, what is the current practice for getting ML style pattern matching syntax in Clojure? many thanks. --~--~-~--~~~---~--~~ You received this message because you

Re: pprint

2009-07-09 Thread Laurent PETIT
Hi Tom, 2009/7/2 Tom Faulhaber tomfaulha...@gmail.com: Are you suggesting that clojure reader parsed code could be first translated back to String and reinjected to the source code reader ? Indeed that could simplify final implementation. I don't know what the impact on performance would

AnotherClojureBox new version!

2009-07-09 Thread Darmac
Hi I just release a new version of AnotherClojureBox!! What's new - Code completion - Inline help while you are writing clojure form (function arguments, etc). - Help form Clojure website pressing F1 over a form. - Form documentation (where available) in the Outout Window pressing Ctrl+1 over a

scheme workshop, should you have free time

2009-07-09 Thread Raoul Duke
http://users.csc.calpoly.edu/~clements/scheme-workshop-2009/ --~--~-~--~~~---~--~~ 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

Best way to create nonref variable?

2009-07-09 Thread Conrad
Hi everyone: I'm trying to optimize an inner loop and need a variable that mutates to make this work. It does NOT need to be a thread-safe variable. What's the best way to create a plain ol' mutating variable in Clojure? I know I can always use an Atom, but I was wondering if there's a more

Re: Best way to create nonref variable?

2009-07-09 Thread Conrad
I suspect the answer will be that I should use atoms (despite the fact that it isn't completely low level) since I see RH uses those in his memoization example, which is pretty much the epitemy of optimizing with a mutating local variable. :-) On Jul 9, 7:56 pm, Conrad drc...@gmail.com wrote:

Re: Best way to create nonref variable?

2009-07-09 Thread Daniel Lyons
On Jul 9, 2009, at 5:56 PM, Conrad wrote: Hi everyone: I'm trying to optimize an inner loop and need a variable that mutates to make this work. It does NOT need to be a thread-safe variable. What's the best way to create a plain ol' mutating variable in Clojure? I know I can always use

Re: Clojure in Clojure?

2009-07-09 Thread John Harrop
On Thu, Jul 9, 2009 at 11:10 AM, tmountain tinymount...@gmail.com wrote: I just finished watching the Bay Area Clojure Meetup video, and Rich spent a few minutes talking about the possibility of Clojure in Clojure. The prospect of having Clojure self-hosted is incredibly cool, but it brought

Re: Best way to create nonref variable?

2009-07-09 Thread J. McConnell
On Thu, Jul 9, 2009 at 7:56 PM, Conraddrc...@gmail.com wrote: I'm trying to optimize an inner loop and need a variable that mutates to make this work. It does NOT need to be a thread-safe variable. What's the best way to create a plain ol' mutating variable in Clojure? I know I can always

Bug with struct-maps and *print-dup*

2009-07-09 Thread Mark Engelberg
I'm running Clojure 1.0. Could someone please check and see whether this is still a bug in the most current version? (use 'clojure.contrib.duck-streams) (defstruct t :a) (def x (struct-map t :a 1)) (def s (binding [*print-dup* true] (with-out-str (pr x (read-string s) ERROR:

Re: Clojure in Clojure?

2009-07-09 Thread Wilson MacGyver
Yea, for me, being on JVM is one of clojure's biggest selling point. I don't know that I would've learn and use clojure were it not on the JVM. On Thu, Jul 9, 2009 at 4:24 PM, John Harropjharrop...@gmail.com wrote: On Thu, Jul 9, 2009 at 11:10 AM, tmountain tinymount...@gmail.com wrote: I