Re: ANN: Upcoming Clojure events (now with an 864 core Azul box)

2009-07-08 Thread Krukow
Line break errors: On Jul 9, 6:34 am, Krukow wrote: > * Introducing Clojure [http://jaoo.dk/aarhus-2009/presentation/ > Introducing+Clojure] http://jaoo.dk/aarhus-2009/presentation/Introducing+Clojure > * The Clojure Concurrency Story [http://jaoo.dk/aarhus-2009/ > presentation/The+Clojure+Con

ANN: Upcoming Clojure events (now with an 864 core Azul box)

2009-07-08 Thread Krukow
Hello everyone, I thought I would take the liberty and announce a number of upcoming Clojure events. Rich Hickey is speaking at the JAOO Aarhus 2009 conference. Rich has two talks: * Introducing Clojure [http://jaoo.dk/aarhus-2009/presentation/ Introducing+Clojure] * The Clojure Concurrency Sto

Re: Clojure box - loading book examples from "Programming Clojure"

2009-07-08 Thread Robert Campbell
> Wherever the files goes after C-x C-f ~/.emacs and then C-x C-s is where > emacs thinks your home directory is. I would just go with that. It's > normally in %appdata%, but it won't be there until you create it and save > it. yes, this is better than my #2 > Robert? Is that all you have in you

Idea for contrib.def: defmemo

2009-07-08 Thread samppi
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 (def {:doc docstring} function (memoize (fn ...)))s. Would th

Re: Clojure box - loading book examples from "Programming Clojure"

2009-07-08 Thread Shawn Hoover
On Wed, Jul 8, 2009 at 2:56 PM, Mani 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 > ~/.emacs" - und

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

2009-07-08 Thread John Harrop
On Wed, Jul 8, 2009 at 4:57 PM, Frantisek Sodomka wrote: > > So far it seems that vectors win in Clojure: > > (timings 3e5 > (let [v (vector 1 2 3) a (nth v 0) b (nth v 1) c (nth v 2)] (+ a b > c)) > (let [lst (list 1 2 3) a (nth lst 0) b (nth lst 1) c (nth lst 2)] (+ > a b c))) > > => > 680.63

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

2009-07-08 Thread Jonathan Smith
Seperate so it can be easily ignored: Changed in core.clj: (defn nth "Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for s

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

2009-07-08 Thread Jonathan Smith
On Jul 8, 4:57 pm, Frantisek Sodomka wrote: > So far it seems that vectors win in Clojure: > > (timings 3e5 >   (let [v (vector 1 2 3) a (nth v 0) b (nth v 1) c (nth v 2)] (+ a b > c)) >   (let [lst (list 1 2 3) a (nth lst 0) b (nth lst 1) c (nth lst 2)] (+ > a b c))) > > => >   680.63 ms   83.6%

Re: Help with example from "A Field Guide to Genetic Programming"

2009-07-08 Thread Timothy Pratley
> user> (def my-func (list + 1 2)) > #'user/my-func > user> (my-func) A list is not a function. Expanded: ((list + 1 2)) The first item in the outer list is a list, it is not a function. So to invoke the function you need to get it using first. Eval call on a list is evaluating a list, and the fi

Re: Help with example from "A Field Guide to Genetic Programming"

2009-07-08 Thread Richard Newman
> Any expression can be evaluated with eval. As, indeed, can self-evaluating forms: user=> (eval 3) 3 user=> (eval (eval (eval (list + 1 2 3 user=> (eval :foo) :foo user=> (eval '+) # user=> (eval 'eval) # This kind of fiddling around in a REPL is very enlightening. --~--~-~--~--

Re: Clojure cheat sheet

2009-07-08 Thread Wilson MacGyver
No no, that's not it. I merely suggested dzone.com because they generally promote their refcards, and I thought it would be a good way for clojure to get some press, and for you to get some fame. :) On Wed, Jul 8, 2009 at 1:49 PM, Steve Tayon wrote: > On 8 Jul., 19:03, Wilson MacGyver wrote: >>

Re: zip of docs?

2009-07-08 Thread Raoul Duke
> It looks like anyone with Organizer rights on Clojure's wikispaces wiki > should be able to export an HTML or WikiText backup zip file. is that different than clojure.org? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google G

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Jurjen
I seem to be lagging a little in the conversation, but for what it's worth, the code I use to capture function definitions is: (defmacro mkfn "Create a function and record the source in the var metadata" [name & fdecl] (list* `defn (with-meta name (assoc (meta name) :source (s

Re: Help with example from "A Field Guide to Genetic Programming"

2009-07-08 Thread John Harrop
On Wed, Jul 8, 2009 at 1:57 PM, Robert Campbell wrote: > If it's okay, could somebody explain the difference between what's > happening here: > > user> (def my-func (list + 1 2)) > #'user/my-func > user> (my-func) > ; Evaluation aborted. > > and here: > > user> (def my-func (list + 1 2)) > #'user

Re: Trouble specifying a gen-class constructor taking an argument of the class being created

2009-07-08 Thread Garth Sheldon-Coulson
I think you're right. Thanks. At this point I'll just work around it rather than patching, but it's good to know people are thinking about it---even if Rich has set the ticket to "Backlog." And thanks Richard... I didn't even know PascalCase had a name =). On Wed, Jul 8, 2009 at 2:00 PM, Chouser

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Daniel
On Wed, Jul 8, 2009 at 11:37 PM, Phil Hagelberg wrote: > > Robert Campbell writes: > >> The main reason this is an issue for me is during development I >> sometimes find I need another library added to my classpath. Right now >> the only way I know how to modify the classpath in Emacs is to chang

Re: zip of docs?

2009-07-08 Thread Justin Johnson
It looks like anyone with Organizer rights on Clojure's wikispaces wiki should be able to export an HTML or WikiText backup zip file. Justin On Wed, Jul 8, 2009 at 3:23 PM, Raoul Duke wrote: > > is there an archive of e.g. http://clojure.org/Reference i can > download for offline work? i haven'

Re: Clojure box - loading book examples from "Programming Clojure"

2009-07-08 Thread Mani
Robert? Is that all you have in your .emacs? I am looking to create one from scratch. I noticed that you have clojure / clojure-contrib jars in your .emacs, but what about slime/swank settings? won't they be overridden by Clojure Box -settings or other way - .emacs loading without slime/ swank? (

Re: Clojure box - loading book examples from "Programming Clojure"

2009-07-08 Thread Mani
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 ~/.emacs" - under my home-directory (C:\emacs). Should i just create a

Re: Clojure cheat sheet

2009-07-08 Thread Steve Tayon
Laurent PETIT schrieb: > Hi, interesting, thanks for doing this ! > > Maybe you could add also the reader syntax for lists (), vectors [], > sets #{}, maps {} or do you think they are too trivial to be in the > cheat sheet ? Although the initialisation of lists, vectors etc. is a reader task, I w

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

2009-07-08 Thread Frantisek Sodomka
So far it seems that vectors win in Clojure: (timings 3e5 (let [v (vector 1 2 3) a (nth v 0) b (nth v 1) c (nth v 2)] (+ a b c)) (let [lst (list 1 2 3) a (nth lst 0) b (nth lst 1) c (nth lst 2)] (+ a b c))) => 680.63 ms 83.6% 1.2x (let [v (vector 1 2 3) a (nth v 0) b (nth v 1) c (nth

zip of docs?

2009-07-08 Thread Raoul Duke
is there an archive of e.g. http://clojure.org/Reference i can download for offline work? i haven't found it yet if there is :-) thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: Questions / guidelines for adopting Clojure

2009-07-08 Thread Vagif Verdi
On Jul 7, 4:08 am, Roman Roelofsen wrote: > * Parametrization of "function groups" * > > Lets say I have a bunch of functions that provide database operations > (read, write, delete, ...). They all share information about the > database the operate on. In an OO language, I would define these > me

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Richard Newman
> I hate to go completely off topic, but could you explain what advices > are in Lisp? When I was reading a post by Steve Yegge he wrote CLOS (the Common Lisp Object System) has before, around, and after methods. Advice is similar, and certainly informed the CL standard. So far as I understan

Re: Clojure box - loading book examples from "Programming Clojure"

2009-07-08 Thread Shawn Hoover
Sorry, the snippet author was Daniel Lyons. Here's a link to the other thread: http://groups.google.com/group/clojure/browse_thread/thread/6198db7d82610293 On Wed, Jul 8, 2009 at 2:14 PM, Shawn Hoover wrote: > Oh, here's an example snippet I just saw from Daniel Lyon on another thread > (note ho

Re: Clojure box - loading book examples from "Programming Clojure"

2009-07-08 Thread Shawn Hoover
Oh, here's an example snippet I just saw from Daniel Lyon on another thread (note how it cleverly grabs all the jars from the ~/.clojure directory--you could add another one of these for another directory of jars): (setq swank-clojure-extra-classpaths (cons "/Users/fusion/Projects/Languages/

Re: Clojure box - loading book examples from "Programming Clojure"

2009-07-08 Thread Robert Campbell
1. Here is my .emacs I use for Clojure Box to load the Jars and add the proper paths to your classpath: (setq swank-clojure-extra-classpaths '()) (add-to-list 'swank-clojure-extra-classpaths "C:/Dev/clojure/clojure.jar") (add-to-list 'swank-clojure-extra-classpaths

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Robert Campbell
Phil - got it. It wouldn't be hard at all to write a script to monitor a directory, and any jar you throw in there gets exploded to the classpath dir like you use. That would make it pretty painless. > For the record, this is usually termed "dribbling" in the Lisp world. > It's very handy for deb

Re: Questions / guidelines for adopting Clojure

2009-07-08 Thread Rayne
On Jul 7, 7:08 am, Roman Roelofsen wrote: > Hi all! > > I've been playing around with Clojure in the last couple of days. Very > interesting! However, I have never used a non-OO, lispy, pure > functional language before and several questions popped up while > snip Clojure is /not/ a pure funct

Re: Clojure box - loading book examples from "Programming Clojure"

2009-07-08 Thread Shawn Hoover
On Wed, Jul 8, 2009 at 2:55 AM, dumb me wrote: > > Hi All, > > I am a dumb around here. my first post among many to come :) > > I setup clojurebox to work thru the book. I am a newbie to emacs and > to clojure. I don't mind the learning curve to emacs. > > I am completely blank about configuring

Re: Trouble specifying a gen-class constructor taking an argument of the class being created

2009-07-08 Thread Chouser
On Wed, Jul 8, 2009 at 7:57 AM, Garth Sheldon-Coulson wrote: > > Hello, > > Does anyone know a straightforward way to create a constructor using > gen-class that takes an argument of the same class as the class you're > generating? I think what you're describing is: http://www.assembla.com/spaces

Re: Calling static methods on a variable holding a class

2009-07-08 Thread Nicolas Buduroi
> Lets say you want to call static method "foo" of a class, > but you don't know which class -- you want this to be > specified at runtime in a parameter. Something like this: > > (defn map-foo [cls coll] > (map cls/foo coll)) ; doesn't work > > As mentioned by others, one approach is to u

Re: Help with example from "A Field Guide to Genetic Programming"

2009-07-08 Thread Robert Campbell
That's it, that's exactly what I needed to complete this example. I'm pretty pumped because you guys have shown me a way to do it without macros and without manually managing a quoted tree structure. If it's okay, could somebody explain the difference between what's happening here: user> (def my

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

2009-07-08 Thread John Harrop
Interesting. How are these timings affected if you add in the time taken to pack the list or vector in the first place, though? I have the feeling it may be slightly cheaper to unpack a vector, but noticeably cheaper to pack a list... --~--~-~--~~~---~--~~ You recei

Re: Newbie macro problems

2009-07-08 Thread Jonas Enlund
2. http://gist.github.com/142939 On Wed, Jul 8, 2009 at 7:19 PM, Jonas Enlund wrote: > 1. Ok, I'll consider that. > > 2. Yes, I'll post a link when I have uploaded the code somewhere. > > 3. It has not yet arrived > > 4. No. I have two sources of inspiration. Pattern matching in PLT > Scheme and

Re: Newbie macro problems

2009-07-08 Thread Jonas Enlund
1. Ok, I'll consider that. 2. Yes, I'll post a link when I have uploaded the code somewhere. 3. It has not yet arrived 4. No. I have two sources of inspiration. Pattern matching in PLT Scheme and this link: http://groups.csail.mit.edu/mac/users/gjs/6.945/psets/ps05/ps.txt (which is almost SICP

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Richard Newman
> Perhaps instead of saving an image, it should be able to save a > transcript > of the REPL inputs? Then you could rescue code from this, or find > any cruft > your image had become dependent on, or whatever. For the record, this is usually termed "dribbling" in the Lisp world. It's very h

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Phil Hagelberg
Robert Campbell writes: > Doesn't this seem a little crazy though? My day job is Java dev in > Eclipse and a little IntelliJ and both IDEs allow you to modify > classpath at any time. It seems like it would be a basic requirement > for any IDE. Think of how often you do this. If I had to reboot

Re: Trouble specifying a gen-class constructor taking an argument of the class being created

2009-07-08 Thread Richard Newman
> Does anyone know a straightforward way to create a constructor using > gen-class that takes an argument of the same class as the class you're > generating? I've actually hit a related problem: a generated class cannot have type annotations for itself (because, as you've noticed, the class d

Re: Using Clojure for complex database driven applications

2009-07-08 Thread Meikel Brandmeyer
Hi, Am 08.07.2009 um 12:10 schrieb Baishampayan Ghose: How mature are they? Do they work well with PostgreSQL? Apparently, ClojureQL doesn't. ClojureQL is not very mature at the moment. Eg. the join syntax will change soon. Other parts need clean up. Basic things are still missing. We cannot

Re: Help with example from "A Field Guide to Genetic Programming"

2009-07-08 Thread Richard Newman
> That looks like what I'm after. When I run a test, however, it doesn't > behave properly: You'll want to either eval the expression, or apply the first item in the list to the rest: user=> (eval (list + 1 2)) 3 user=> (let [form (list + 1 2)] (when (not (empty? form)) (apply (first f

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Robert Campbell
>> Unfortunately this is impossible due to the way the classloaders in >> the >> JVM work; you can't modify your classpath at runtime and have it work >> consistently. Doesn't this seem a little crazy though? My day job is Java dev in Eclipse and a little IntelliJ and both IDEs allow you to modif

Re: Using Clojure for complex database driven applications

2009-07-08 Thread Wilson MacGyver
Lau, one of the co-developer sad he was working on pgsql, I haven't tried it with pgsql. I'm sure he'll jump in here. :) As for maturity, apprently 1.0 release is near. I only tried some limited queries so far. You should stress test it for your project. On 7/8/09, Baishampayan Ghose wrote: > W

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread mccraigmccraig
what's the problem with adding urls to the current ClassLoader ? i've seen remarks to the effect that it doesn't work well, but i don't understand why... c On 8 Jul 2009, at 17:37, Phil Hagelberg wrote: > > Robert Campbell writes: > >> The main reason this is an issue for me is during devel

Re: Clojure cheat sheet

2009-07-08 Thread Wilson MacGyver
Great idea, maybe you should talk to dzone.com about turning this into a refcard. On Jul 8, 2009, at 5:04 AM, Steve Tayon wrote: > > Hello everyone, > > while looking around for a modern lisp, I discovered Clojure and was > instantly infected by the new possibilities to write software. Sinc

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Daniel Lyons
On Jul 8, 2009, at 10:22 AM, Sean Devlin wrote: > Isn't this why you would use a doc string, and not a comment? Docstrings aren't the only comments in my code. :) — Daniel Lyons --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Homoiconicity and printing functions

2009-07-08 Thread Meikel Brandmeyer
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 VimClojure for development) Am 08.07.2009 um 16:39 schrieb Mike:

Re: Newbie macro problems

2009-07-08 Thread Laurent PETIT
2009/7/8 Sean Devlin : > > Laurent, > > I don't quite understand your point.  Could you please explain it a > little more? Oh, I wanted to be quick. I think using the term "array" instead of "vector" (which is the real term used for datastructure created by a [:a :b :c :d] form) may be confusing

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Phil Hagelberg
Robert Campbell writes: > The main reason this is an issue for me is during development I > sometimes find I need another library added to my classpath. Right now > the only way I know how to modify the classpath in Emacs is to change > the .emacs file with an add-to-list 'swank-clojure-extra-cl

Re: Newbie macro problems

2009-07-08 Thread Sean Devlin
Good point. I'll be careful to use the term vector in the future, and array for java interop only. On Jul 8, 12:30 pm, Laurent PETIT wrote: > 2009/7/8 Sean Devlin : > > > > > Laurent, > > > I don't quite understand your point.  Could you please explain it a > > little more? > > Oh, I wanted to

Re: Homoiconicity and printing functions

2009-07-08 Thread Phil Hagelberg
Mike writes: > I'm using that JLine thing for command history, but I would imagine > it's completely oblivious to Clojure forms so they get split > (potentially, depending on how I typed it) on multiple lines. It's easy to get in a state where you're not sure how to reproduce it if you enter a

Re: Starting REPL in vimclojure

2009-07-08 Thread Meikel Brandmeyer
Hi, Am 08.07.2009 um 16:56 schrieb Bart J: I have setup vimclojure but am unable to start the REPL. When I give the foll. "call vimclojure#Repl.New()" in vim I get the foll. error: Couldn't execute Nail! java.lang.NoClassDefFoundError: Could not initialize class de.kotka.vimclojure.nails.Repl

Re: Dependency management

2009-07-08 Thread Phil Hagelberg
Daniel writes: > I would very much like to see that people don't suffer the NIH > syndrome everywhere. Usually people forget that every alternative > technology implemented has an associated cost that everyone looking > for a solution has to pay, because I have to consciously discard the > tool

Re: Newbie macro problems

2009-07-08 Thread Sean Devlin
Laurent, I don't quite understand your point. Could you please explain it a little more? Thanks On Jul 8, 12:16 pm, Laurent PETIT wrote: > 2009/7/8 Sean Devlin : > > > > > This seems like a good use for a macro.  A couple of thoughts: > > > 1.  Use arrays instead of lists > > In clojure, it i

Re: Is this unquote dangerous?

2009-07-08 Thread Nathan Kitchen
On Jul 7, 5:02 am, Mike wrote: > (not sure where my reply to Chouser et al. went, but basically I said > that I was writing a macro and I might be overdoing it.  I was right!) > > Here's what I was trying to accomplish, but in functions, not macros: > > (defn slice >   "Returns a lazy sequence co

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Sean Devlin
Isn't this why you would use a doc string, and not a comment? On Jul 8, 12:14 pm, Daniel Lyons wrote: > On Jul 8, 2009, at 5:46 AM, Robert Campbell wrote: > > > It seems strange to me that Clojure doesn't support this concept   > > natively > > Comments are part of the problem. Clojure's reader

Re: Clojure cheat sheet

2009-07-08 Thread Laurent PETIT
Hi, interesting, thanks for doing this ! Maybe you could add also the reader syntax for lists (), vectors [], sets #{}, maps {} or do you think they are too trivial to be in the cheat sheet ? Regards, -- Laurent 2009/7/8 Steve Tayon : > > Mark Volkmann schrieb: >> Looks good! You might get so

Re: Newbie macro problems

2009-07-08 Thread Laurent PETIT
2009/7/8 Sean Devlin : > > This seems like a good use for a macro.  A couple of thoughts: > > 1.  Use arrays instead of lists > In clojure, it is "best practice" to use arrays for data.  So, your > macro call should look like this. > > (match [1 2 3] >       [1 x]   (+ x x) >       [1 x y] (+ x y)

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Daniel Lyons
On Jul 8, 2009, at 5:46 AM, Robert Campbell wrote: > It seems strange to me that Clojure doesn't support this concept > natively Comments are part of the problem. Clojure's reader strips them out while parsing before compiling the function, so you would lose them during the first round-t

Re: Newbie macro problems

2009-07-08 Thread Sean Devlin
4. Is this example from SICP? On Jul 8, 12:12 pm, Sean Devlin wrote: > This seems like a good use for a macro.  A couple of thoughts: > > 1.  Use arrays instead of lists > In clojure, it is "best practice" to use arrays for data.  So, your > macro call should look like this. > > (match [1 2 3]

Re: Newbie macro problems

2009-07-08 Thread Sean Devlin
This seems like a good use for a macro. A couple of thoughts: 1. Use arrays instead of lists In clojure, it is "best practice" to use arrays for data. So, your macro call should look like this. (match [1 2 3] [1 x] (+ x x) [1 x y] (+ x y)) 2. Could you post the source to mat

Re: Homoiconicity and printing functions

2009-07-08 Thread Richard Newman
> How do folks interactively code with a REPL and then once things > "settle down" dump it back out so you can make a proper module out of > it? Typically, folks don't. Use Vim, Emacs, Eclipse... any tool that provides an interactive Clojure toplevel and the ability to evaluate forms within fi

Newbie macro problems

2009-07-08 Thread Jonas
Hi. I'm developing a simple pattern matching library for clojure but I am having trouble with macros (which I have almost zero experience with). I have a function `make-matcher` (make-matcher ) which returns a function that can pattern match on data and returns a map of bindings (or nil in cas

Starting REPL in vimclojure

2009-07-08 Thread Bart J
I have setup vimclojure but am unable to start the REPL. When I give the foll. "call vimclojure#Repl.New()" in vim I get the foll. error: Couldn't execute Nail! java.lang.NoClassDefFoundError: Could not initialize class de.kotka.vimclojure.nails.Repl at java.lang.Class.forName0(Native Method) at

Re: Clojure box - loading book examples from "Programming Clojure"

2009-07-08 Thread dumb me
anyone? Has anyone worked on Clojure box with the book examples? Last thing I tried was to load a single file (load-file "c:\emacs\code \examples\introduction.clj") and what I get is the last program in that file. thanks. On Jul 8, 2:55 pm, dumb me wrote: > Hi All, > > I am a dumb around here

Re: Homoiconicity and printing functions

2009-07-08 Thread Mike
On Jul 8, 10:14 am, "Stephen C. Gilardi" wrote: > Once it's compiled, it's JVM bytecode. I'm not aware of a tool that   > could decompile it into Clojure code, even in a low-level form. That's what I was afraid of. How do folks interactively code with a REPL and then once things "settle down" d

Re: Clojure cheat sheet

2009-07-08 Thread Steve Tayon
Mark Volkmann schrieb: > Looks good! You might get some additional ideas for categories from > http://java.ociweb.com/mark/clojure/ClojureCategorized.html. Thanks for the hint. I will look for missing commands and merge them into the sheet. Steve --~--~-~--~~~---~--~

Re: Homoiconicity and printing functions

2009-07-08 Thread John Harrop
On Wed, Jul 8, 2009 at 9:11 AM, Mike wrote: > One of the things that drew me to Clojure was the fact that it's > homoiconic (and my previous lisp [Scheme] was not necessarily), which > means code is data, macro writing is easy etc. etc. > > What I'm missing is why I can't print a function. I und

Re: Calling static methods on a variable holding a class

2009-07-08 Thread Chouser
On Wed, Jul 8, 2009 at 10:23 AM, Nicolas Buduroi wrote: > >> If you know the method you wish to call, do you not know the class and can >> thus call the static method directly? > > Well that was the point of the question, that is if I have to call a > static method on a class we don't know in adva

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

2009-07-08 Thread Frantisek Sodomka
To compare timings, I use this macro: (defmacro time-ms [n expr] `(let [start# (. System (nanoTime))] (dotimes [i# ~n] ~expr) (/ (double (- (. System (nanoTime)) start#)) 100.0))) (defmacro timings [n & expr] (let [expr-are-not-equal (cons 'not= expr) expr-times (co

[ANN] clj-peg 0.4

2009-07-08 Thread Richard Lyman
Version 0.4 brings modifications to the syntax for declaring grammars as well as suggestions about avoiding the exponential runtimes that can occur. Here is a post walking through these changes . -Rich --~--~-

Re: Calling static methods on a variable holding a class

2009-07-08 Thread Nicolas Buduroi
> If you know the method you wish to call, do you not know the class and can > thus call the static method directly? Well that was the point of the question, that is if I have to call a static method on a class we don't know in advance. I understand this capability isn't that useful and is quite

Re: Homoiconicity and printing functions

2009-07-08 Thread Stephen C. Gilardi
On Jul 8, 2009, at 9:11 AM, Mike wrote: What I'm missing is why I can't print a function. I understand that most of the functions I write use quite a few macros, and after expansion into the core forms it looks shredded...but isn't there any way for me to see a representation of this "source"

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Josh Daghlian
I half-solve the "what have I defined?" problem with a combination of: 1) trying to always work from a file rather than entering stuff by hand at the repl 2) always working in a "scrap" namespace whose contents I can inspect using ns-interns and clojure.inspector/inspect-tree, like so: user=> (n

Homoiconicity and printing functions

2009-07-08 Thread Mike
One of the things that drew me to Clojure was the fact that it's homoiconic (and my previous lisp [Scheme] was not necessarily), which means code is data, macro writing is easy etc. etc. What I'm missing is why I can't print a function. I understand that most of the functions I write use quite a

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Michael Wood
2009/7/8 John Harrop : > On Wed, Jul 8, 2009 at 5:14 AM, Robert Campbell wrote: >> >> Thanks Daniel, that makes perfect sense, especially about having >> random - and forgotten - code in the image. I have a lot of this >> during my exploration sessions. > > Perhaps instead of saving an image, it

Re: Clojure cheat sheet

2009-07-08 Thread Mark Volkmann
Looks good! You might get some additional ideas for categories from http://java.ociweb.com/mark/clojure/ClojureCategorized.html. On Wed, Jul 8, 2009 at 4:04 AM, Steve Tayon wrote: > > Hello everyone, > > while looking around for a modern lisp, I discovered Clojure and was > instantly infected by

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Robert Campbell
> Perhaps instead of saving an image, it should be able to save a transcript > of the REPL inputs? Then you could rescue code from this, or find any cruft > your image had become dependent on, or whatever. The only problem I see with this approach is that you leave it up to the user (me) to sort

Trouble specifying a gen-class constructor taking an argument of the class being created

2009-07-08 Thread Garth Sheldon-Coulson
Hello, Does anyone know a straightforward way to create a constructor using gen-class that takes an argument of the same class as the class you're generating? When I try to do it I get a ClassNotFoundException, assuming I don't have a previous compiled version of the class in my compile path. B

Re: Using Clojure for complex database driven applications

2009-07-08 Thread Suresh Harikrishnan
Check out clj-record modelled around Rails' ActiveRecord. http://elhumidor.blogspot.com/2009/01/clj-record-activerecord-for-clojure.html http://github.com/duelinmarkers/clj-record/tree/master -Suresh On Wed, Jul 8, 2009 at 3:29 PM, Baishampayan Ghose wrote: > Hello, > > So we are going to develo

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread John Harrop
On Wed, Jul 8, 2009 at 5:14 AM, Robert Campbell wrote: > > Thanks Daniel, that makes perfect sense, especially about having > random - and forgotten - code in the image. I have a lot of this > during my exploration sessions. Perhaps instead of saving an image, it should be able to save a transc

Re: Dependency management

2009-07-08 Thread Daniel
On Wed, Jul 8, 2009 at 11:28 AM, Phil Hagelberg wrote: > > I've been noodling on the problem of dependency management for a while > now. It's definitely a pain point for projects with more than a couple > dependencies. Currently our approach has been to use maven, but that > involves a fair amount

Clojure cheat sheet

2009-07-08 Thread Steve Tayon
Hello everyone, while looking around for a modern lisp, I discovered Clojure and was instantly infected by the new possibilities to write software. Since then I watched the screencasts and read several tutorials. Finally I bought "Programming Clojure" by Stuart and I was impressed by his clean an

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

2009-07-08 Thread John Harrop
On Wed, Jul 8, 2009 at 3:42 AM, Frantisek Sodomka wrote: > > If result is a vector v, then from these 4 cases: > (let [v [1 2 3]] > (let [[a b c] v] a b c) > (let [a (v 0) b (v 1) c (v 2)] a b c) > (let [a (nth v 0) b (nth v 1) c (nth v 2)] a b c) > (let [x (first v) r1 (rest v) y (first r1) r

Clojure box - loading book examples from "Programming Clojure"

2009-07-08 Thread dumb me
Hi All, I am a dumb around here. my first post among many to come :) I setup clojurebox to work thru the book. I am a newbie to emacs and to clojure. I don't mind the learning curve to emacs. I am completely blank about configuring Clojurebox. Here's what I want to do: 1) load all the code-ex

Re: Help with example from "A Field Guide to Genetic Programming"

2009-07-08 Thread Robert Campbell
> It seems to me you want: > user=> (list + 1 2) > (# 1 2) That looks like what I'm after. When I run a test, however, it doesn't behave properly: user> (def my-func (list + 1 2)) #'user/my-func user> (my-func) ; Evaluation aborted. clojure.lang.PersistentList cannot be cast to clojure.lang.IFn

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Robert Campbell
Hi Jurjen, That wrapper for defn is something I was looking for in another post; I previously asked how I can inspect the definitions of my functions on the REPL. When I'm exploring stuff I'll be redefining many functions many times and sometimes I lose track things. I basically have to scroll ar

Re: Using Clojure for complex database driven applications

2009-07-08 Thread Matt Culbreth
> > I am quite used to the way Object Relational Mappers like SQLAlchemy & > Django work in the Python world. > I've recently thought that a good project would be to port SQLAlchemy to Clojure. It wouldn't be a straight port since the languages are so different, but at least SQLAlchemy's query g

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Jurjen
I had the same thought (as posted in the other thread) and haven't come to a final solution yet. The main reason I wanted to achieve it was that I do my developing / tinkering / brainstorming spread over several work boxes spread out through several locations, and a clojure REPL is cheap and easy,

Re: Using Clojure for complex database driven applications

2009-07-08 Thread Baishampayan Ghose
Wilson MacGyver wrote: > Take a look at ClojureQL > > http://github.com/Lau-of-DK/clojureql/tree/master > > It's not a ORM system like SQLAlchemy/Django ORM in that > it won't "manage" the table schema for you. > > There is also clj-record. > > http://github.com/duelinmarkers/clj-record/tree/ma

Re: Using Clojure for complex database driven applications

2009-07-08 Thread Wilson MacGyver
Take a look at ClojureQL http://github.com/Lau-of-DK/clojureql/tree/master It's not a ORM system like SQLAlchemy/Django ORM in that it won't "manage" the table schema for you. There is also clj-record. http://github.com/duelinmarkers/clj-record/tree/master which is inspired by rail's ActiveRe

Using Clojure for complex database driven applications

2009-07-08 Thread Baishampayan Ghose
Hello, So we are going to develop a moderately complex Database driven application in Clojure and I am looking for easy-to-manage solutions for talking to Databases. I am quite used to the way Object Relational Mappers like SQLAlchemy & Django work in the Python world. We define the DB schema us

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Robert Campbell
Thanks Daniel, that makes perfect sense, especially about having random - and forgotten - code in the image. I have a lot of this during my exploration sessions. The main reason this is an issue for me is during development I sometimes find I need another library added to my classpath. Right now

Re: Save current namespace like a Smalltalk image

2009-07-08 Thread Daniel Lyons
Robert, On Jul 8, 2009, at 2:13 AM, Robert Campbell wrote: > Sometimes I have pretty long REPL sessions where I'm trying to flesh > out some ideas. When I close my instance of Clojure Box (Emacs based) > I lose all the definitions I had worked out over time. Is there any > way to dump namespace(

Save current namespace like a Smalltalk image

2009-07-08 Thread Robert Campbell
Hello, Sometimes I have pretty long REPL sessions where I'm trying to flesh out some ideas. When I close my instance of Clojure Box (Emacs based) I lose all the definitions I had worked out over time. Is there any way to dump namespace(s) to an image? It would be great to be able to load up some

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

2009-07-08 Thread Frantisek Sodomka
If result is a vector v, then from these 4 cases: (let [v [1 2 3]] (let [[a b c] v] a b c) (let [a (v 0) b (v 1) c (v 2)] a b c) (let [a (nth v 0) b (nth v 1) c (nth v 2)] a b c) (let [x (first v) r1 (rest v) y (first r1) r2 (rest r1) z (first r2)] x y z)) using 'nth' (let [a (nth v 0) b