Re: Datatypes and protocols - update

2009-12-07 Thread Konrad Hinsen
On 01.12.2009, at 02:42, Rich Hickey wrote: An updated version of the code for datatypes[1] and protocols[2] is now available in the 'new' branch[3]. This weekend I finally got around to converting all my deftype-and- defprotocol-using code to the current Clojure new branch. It is now more

Re: Is it possible to define ordering functions for own type?

2009-12-07 Thread Konrad Hinsen
On 07.12.2009, at 07:52, ataggart wrote: The functions , , =, = are only for numbers (though there might be a way to shadow them). You can use the compare function for anything implementing the Comparable interface (which should be easier to do when using deftype instead of defstruct). You

Multiple dispatch with Multimethods

2009-12-07 Thread Tzach
Hello What is the idiomatic way to implement the classic collide-with function in Clojure? I would like to implement something similar to the following (pseudo code ahead): (defmulti collide-with foo) (defmethod collide-with [asteroid spaceship] (print Boom)) (defmethod collide-with [asteroid

Re: Multiple dispatch with Multimethods

2009-12-07 Thread ataggart
On Dec 7, 1:21 am, Tzach tzach.livya...@gmail.com wrote: Hello What is the idiomatic way to implement the classic collide-with function in Clojure? I would like to implement something similar to the following (pseudo code ahead): (defmulti collide-with foo) (defmethod collide-with

Re: Getting Started in Mac OS X Snow Leopard

2009-12-07 Thread Lauri Pesonen
Thanks everyone for the recommendations. 2009/12/4 Steve Purcell st...@sanityinc.com: Here's what I do (in Cocoa Emacs 23) to make 'option' work the same in Emacs as in other OS X apps:  (setq mac-command-modifier 'meta)  (setq mac-option-modifier 'none)  (setq default-input-method

Re: Getting Started in Mac OS X Snow Leopard

2009-12-07 Thread Lauri Oherd
I have a Macbooc Pro with Sweden keyboard so had a little different issues here - by default not possible to type characters {[]} on Carbon Emacs. I solved it by adding the following to my .emacs file: ;; paredit-mode (add-to-list 'load-path (expand-file-name ~/.emacs.d/paredit)) (autoload

how is leiningen new intended to work?

2009-12-07 Thread B Smith-Mannschott
I'm finding the behavior of leiningen new to be broken. It looks like the initial implementation isn't clear about what exactly the project name given as argument to lein new denotes. I'd like to fix this, but before i hack on a patch, I'd be curious to know how this subcommand was intended to

Re: Getting Started in Mac OS X Snow Leopard

2009-12-07 Thread Lauri Oherd
Sorry, pressed send button too fast - here is correct elisp code: (global-set-key (kbd M-3) (lambda (optional n) (interactive p) (let ((last-command-event 35)) (self-insert-command n On Mon, Dec 7,

Re: Datatypes and protocols - update

2009-12-07 Thread Rich Hickey
On Mon, Dec 7, 2009 at 3:11 AM, Konrad Hinsen konrad.hin...@fastmail.net wrote: On 01.12.2009, at 02:42, Rich Hickey wrote: An updated version of the code for datatypes[1] and protocols[2] is now available in the 'new' branch[3]. This weekend I finally got around to converting all my

Re: Is str supposed to be able to output lazy strings?

2009-12-07 Thread Jim Blomo
clojure-contrib also has a str-join function, which could be helpful for joining SQL conditions: (use '[clojure.contrib.str-utils :only (str-join)]) (str-join AND (map identity [1 2 3])) Jim On Sun, Dec 6, 2009 at 11:03 AM, samppi rbysam...@gmail.com wrote: Also, you should also consider

Re: How to use/refer to multiple Clojure classes

2009-12-07 Thread songoku
It does not look like wildcarding is supported in the ns macro and it seems silly to explicitly nominate each class that I want to have at my disposal. Am I thinking about this all wrong? As far as i know you have to add each of them... -- You received this message because you are subscribed

Re: Clojure development environments

2009-12-07 Thread balln...@googlemail.com
That is a useful hint. Thanks - I'll check that out. On Dec 6, 6:07 am, Phil Hagelberg p...@hagelb.org wrote: balln...@googlemail.com balln...@googlemail.com writes: Emacs /clojure-mode: You need to install git to pull down the latest sources! You needClojureandClojure-contrib (usually you

Re: Multiple dispatch with Multimethods

2009-12-07 Thread Meikel Brandmeyer
Hi, On Dec 7, 10:21 am, Tzach tzach.livya...@gmail.com wrote: (defmulti collide-with foo) (defmethod collide-with [asteroid spaceship] (print Boom)) (defmethod collide-with [asteroid any] (print Wiiissh)) (defmethod collide-with [any spaceship] (print Wooossh)) (defmethod collide-with

Re: Getting Started in Mac OS X Snow Leopard

2009-12-07 Thread Steve Purcell
On 7 Dec 2009, at 11:15, Lauri Pesonen wrote: 2009/12/4 Steve Purcell st...@sanityinc.com: Here's what I do (in Cocoa Emacs 23) to make 'option' work the same in Emacs as in other OS X apps: (setq mac-command-modifier 'meta) (setq mac-option-modifier 'none) (setq default-input-method

Leiningen in Python

2009-12-07 Thread Jonghyouk, Yun
Hi, I've write some python script for leiningen for Windows machines without wget/curl. I expect it is nicer than as-is bourne-shell-script version of 'lein'. here is my little script: http://github.com/ageldama/configs/blob/master/lein/lein.py Thanks. -- You received this message because

Re: Leiningen in Python

2009-12-07 Thread liebke
That's great. Roland Sadowski has also written a Windows-friendly lein script in PowerShell: http://gist.github.com/239210 On Dec 7, 8:15 am, Jonghyouk, Yun ageld...@gmail.com wrote: Hi, I've write some python script for leiningen for Windows machines without wget/curl. I expect it is

Re: Datatypes and protocols - update

2009-12-07 Thread Hugo Duncan
On Mon, 07 Dec 2009 06:53:38 -0500, Rich Hickey richhic...@gmail.com wrote: Yes, methods are not really functions. Thinking about them as closures over the object is a good way to go - you can see that analogy in play when you consider recur, which works with these methods, but could not

Re: Datatypes and protocols - update

2009-12-07 Thread Laurent PETIT
2009/12/7 Hugo Duncan hugodun...@users.sourceforge.net On Mon, 07 Dec 2009 06:53:38 -0500, Rich Hickey richhic...@gmail.com wrote: Yes, methods are not really functions. Thinking about them as closures over the object is a good way to go - you can see that analogy in play when you

Re: The new deftype and multimethod dispatching

2009-12-07 Thread Laurent PETIT
2009/12/6 Bob Hutchison hutch-li...@recursive.ca On 6-Dec-09, at 3:46 PM, Meikel Brandmeyer wrote: Hi, Am 06.12.2009 um 21:29 schrieb Bob Hutchison: It turns out that dispatching on play.foo.Foo is the only way that works. I was hoping ::f/Foo or f/Foo would work too (maybe my

Re: How to use/refer to multiple Clojure classes

2009-12-07 Thread ataggart
On Nov 30, 9:21 am, Dan Kefford dan_keff...@hotmail.com wrote: OK... I'm trying to take Clojure for a spin on Project Euler problems. I have source files for each problem that I have solved and although I can refer to and invoke any one of them explicitly from a main class, I cannot seem to

Re: Datatypes and protocols - update

2009-12-07 Thread ataggart
On Dec 7, 9:07 am, Laurent PETIT laurent.pe...@gmail.com wrote: 2009/12/7 Hugo Duncan hugodun...@users.sourceforge.net On Mon, 07 Dec 2009 06:53:38 -0500, Rich Hickey richhic...@gmail.com wrote: Yes, methods are not really functions. Thinking about them as closures over the object

Re: Datatypes and protocols - update

2009-12-07 Thread ataggart
On Dec 7, 11:23 am, ataggart alex.tagg...@gmail.com wrote: On Dec 7, 9:07 am, Laurent PETIT laurent.pe...@gmail.com wrote: 2009/12/7 Hugo Duncan hugodun...@users.sourceforge.net On Mon, 07 Dec 2009 06:53:38 -0500, Rich Hickey richhic...@gmail.com wrote: Yes, methods are not

how 'bout a debug-repl?

2009-12-07 Thread George Jahad
Every time I stick a println into some Clojure code to debug it, I think to myself, This is Lisp! I should be able to insert a repl here! The problem is of course that Clojure's eval function doesn't know about the surrounding lexical scope. So I started asking myself, what is the simplest change

Re: The new deftype and multimethod dispatching

2009-12-07 Thread Bob Hutchison
On 7-Dec-09, at 12:17 PM, Laurent PETIT wrote: 2009/12/6 Bob Hutchison hutch-li...@recursive.ca On 6-Dec-09, at 3:46 PM, Meikel Brandmeyer wrote: Hi, Am 06.12.2009 um 21:29 schrieb Bob Hutchison: It turns out that dispatching on play.foo.Foo is the only way that works. I was hoping

Re: how 'bout a debug-repl?

2009-12-07 Thread Richard Newman
I'm pretty pleased with the results and wanted to show them off. More details here: http://georgejahad.com/clojure/debug-repl.html Pretty slick work, George! Thanks for sharing! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: The new deftype and multimethod dispatching

2009-12-07 Thread ataggart
On Dec 7, 12:37 pm, Bob Hutchison hutch-li...@recursive.ca wrote: On 7-Dec-09, at 12:17 PM, Laurent PETIT wrote: 2009/12/6 Bob Hutchison hutch-li...@recursive.ca On 6-Dec-09, at 3:46 PM, Meikel Brandmeyer wrote: Hi, Am 06.12.2009 um 21:29 schrieb Bob Hutchison: It turns out

Re: The new deftype and multimethod dispatching

2009-12-07 Thread Bob Hutchison
On 7-Dec-09, at 4:16 PM, ataggart wrote: On Dec 7, 12:37 pm, Bob Hutchison hutch-li...@recursive.ca wrote: On 7-Dec-09, at 12:17 PM, Laurent PETIT wrote: 2009/12/6 Bob Hutchison hutch-li...@recursive.ca Yes! Thanks! The dispatch on type rather than class is the trick. I actually ended up

new API webpage format

2009-12-07 Thread cej38
Hi, I am writing because there seem to be missing functions in the API webpage. The only one that I know for sure at the moment is the filter function. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

hyphens vs. underscores for lib names

2009-12-07 Thread Raoul Duke
hi, why does that translation happen? is there some java issue/requirement? thanks. -- 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 are moderated - please

Re: hyphens vs. underscores for lib names

2009-12-07 Thread Richard Newman
why does that translation happen? is there some java issue/ requirement? I don't think '-' is valid in a Java class name. http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#40625 user= (Character/isJavaIdentifierPart \-) false user= (Character/isJavaIdentifierPart \_)

Embedding a REPL

2009-12-07 Thread Mike
I've seen an example of launching a Clojure script from Java (http:// en.wikibooks.org/wiki/Clojure_Programming/ Tutorials_and_Tips#Invoking_Clojure_from_Java), but I've got an application in which I'd like to run a REPL. My app has its own JPanel for display results, and a text area for input,

Re: Datatypes and protocols - update

2009-12-07 Thread DTH
On Dec 1, 9:56 pm, Rich Hickey richhic...@gmail.com wrote: There are 2 ways to make a deftype reach a protocol. First, you can implement the protocol directly in the deftype/reify, supplying the protocol where you do interfaces, and the methods of the protocol as methods of the type. The type

Re: The new deftype and multimethod dispatching

2009-12-07 Thread Meikel Brandmeyer
Hi, Am 07.12.2009 um 21:37 schrieb Bob Hutchison: Please note that in clojure, it's the dispatch on the class that's the trick, not on the type ;-) Sorry, I don't understand what you mean. Could you expand on that a bit? Dispatch on the class (or interface) is sometimes the trick in

Re: The new deftype and multimethod dispatching

2009-12-07 Thread Bob Hutchison
On 7-Dec-09, at 4:05 PM, Meikel Brandmeyer wrote: Hi, Am 07.12.2009 um 21:37 schrieb Bob Hutchison: Please note that in clojure, it's the dispatch on the class that's the trick, not on the type ;-) Sorry, I don't understand what you mean. Could you expand on that a bit? Dispatch

Re: new API webpage format

2009-12-07 Thread Tom Faulhaber
By golly, you're right. I'll take a look at why. On Dec 7, 2:14 pm, cej38 junkerme...@gmail.com wrote: Hi,   I am writing because there seem to be missing functions in the API webpage.  The only one that I know for sure at the moment is the filter function. -- You received this message

Re: hyphens vs. underscores for lib names

2009-12-07 Thread Raoul Duke
I don't think '-' is valid in a Java class name. makes sense, and i learn something new every day... thanks. -- 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

Re: Generalizing - -

2009-12-07 Thread Cliff Wells
On Sat, 2009-12-05 at 13:14 +0100, Konrad Hinsen wrote: On 4 Dec 2009, at 23:23, Cliff Wells wrote: What isn't clear to me is exactly what a piece of paper provides that an electronic form doesn't (aside from inconvenience). I don't see any A clear legal status all over the world.

Re: how is leiningen new intended to work?

2009-12-07 Thread devender
I am no expert at this, but this is what I have done 1. lein new mytestprj 2. go into the newly created dir and edit the project.clj and rename from 'leiningen' to mytestprj (I think this is why your jar was getting named leiningen.jar). 3. then do a 'lein deps' to copy the required libs into the

Trouble implementing Dijkstra algorithm in Clojure

2009-12-07 Thread ajay
Hi all, I am new to FP in general and I am trying to pick up Clojure. I am having trouble thinking in FP terms. I am trying to implement the Dijkstra algorithm for shortest paths in Graph in Clojure. If this succeeds, I will implement all the advanced graph algos I am learning in this course in

Re: Embedding a REPL

2009-12-07 Thread Liam
I think the following is “looked down upon” or “discouraged“, but I managed to sift through how clojure itself handles its own stuff in java and I came up with the following. Say, that you want to set *out*, *in*, and *err* in clojure to something from Java before starting a REPL. Here is how I

Re: new API webpage format

2009-12-07 Thread Howard Lewis Ship
I still think it would be neat if there was some DHTML coolness to help narrow down the symbol names that come down the right side of the page. On Mon, Dec 7, 2009 at 4:00 PM, Tom Faulhaber tomfaulha...@gmail.com wrote: By golly, you're right. I'll take a look at why. On Dec 7, 2:14 pm, cej38

Re: new API webpage format

2009-12-07 Thread Tom Faulhaber
Yup, I heard that the first time :-) It's coming, but not right this sec. Tom On Dec 7, 4:57 pm, Howard Lewis Ship hls...@gmail.com wrote: I still think it would be neat if there was some DHTML coolness to help narrow down the symbol names that come down the right side of the page. On

Possible BUG: NPE

2009-12-07 Thread Feng
Hi, After git pull on new branch commit 1da63ad10d2531264e86eb705a10b3cebc9b1067 Author: Rich Hickey richhic...@gmail.com Date: Mon Dec 7 16:44:41 2009 -0500 init CLEAR_SITES Got NPE in slime java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException:

Re: Possible BUG: NPE

2009-12-07 Thread David Nolen
I was getting this as well, but this was before the last 3 commits to new. Did you wipe your old jars and class files and start afresh? David On Mon, Dec 7, 2009 at 8:31 PM, Feng hou...@gmail.com wrote: Hi, After git pull on new branch commit 1da63ad10d2531264e86eb705a10b3cebc9b1067

Re: Possible BUG: NPE

2009-12-07 Thread Feng
On Dec 7, 8:57 pm, David Nolen dnolen.li...@gmail.com wrote: I was getting this as well, but this was before the last 3 commits to new. Did you wipe your old jars and class files and start afresh? Yes, just to make sure not waste Rich's time. I did doubt and triple checks, ant clean, find

Re: Possible BUG: NPE

2009-12-07 Thread David Nolen
Looking at the stacktrace it looks like this is because of swank_fuzzy.clj. I can start up the SLIME Repl no problem, I see your exact same stack trace only if I try to trigger fuzzy completion via C-c TAB. David On Mon, Dec 7, 2009 at 9:24 PM, Feng hou...@gmail.com wrote: On Dec 7, 8:57 pm,

Re: Possible BUG: NPE

2009-12-07 Thread David Nolen
http://github.com/jochu/swank-clojure/blob/master/src/main/clojure/swank/commands/contrib/swank_fuzzy.clj#L256 Is the offending line. On Mon, Dec 7, 2009 at 9:34 PM, David Nolen dnolen.li...@gmail.com wrote: Looking at the stacktrace it looks like this is because of swank_fuzzy.clj. I can

Re: new API webpage format

2009-12-07 Thread ataggart
While we're throwing requests at Tom, it'd be nice if the special forms were included in the api. On Dec 7, 5:21 pm, Tom Faulhaber tomfaulha...@gmail.com wrote: Yup, I heard that the first time :-) It's coming, but not right this sec. Tom On Dec 7, 4:57 pm, Howard Lewis Ship

Re: Trouble implementing Dijkstra algorithm in Clojure

2009-12-07 Thread ataggart
On Dec 7, 4:19 pm, ajay ajgop...@gmail.com wrote: Hi all, I am new to FP in general and I am trying to pick up Clojure. I am having trouble thinking in FP terms. I am trying to implement the Dijkstra algorithm for shortest paths in Graph in Clojure. If this succeeds, I will implement all

Re: Possible BUG: NPE

2009-12-07 Thread Feng
Yes, fuzzy-completion seems the only way to trigger it. For what it's worth, it did not happen if reset to commit a3e95cf5a72b22cd0728aba152d5f77603b722fc Author: Rich Hickey richhic...@gmail.com Date: Fri Dec 4 11:22:04 2009 -0500 update example in reify doc - Feng On Dec 7, 9:34 pm,

Re: Trouble implementing Dijkstra algorithm in Clojure

2009-12-07 Thread harrison clarke
you can use recur. it calls the fn/loop it's contained in with new args. (so, with the updated array and queue) On Dec 7, 8:19 pm, ajay ajgop...@gmail.com wrote: Hi all, I am new to FP in general and I am trying to pick up Clojure. I am having trouble thinking in FP terms. I am trying to

Re: new API webpage format

2009-12-07 Thread Garth Sheldon-Coulson
inc Thanks for the hard work. On 12/7/09, ataggart alex.tagg...@gmail.com wrote: While we're throwing requests at Tom, it'd be nice if the special forms were included in the api. On Dec 7, 5:21 pm, Tom Faulhaber tomfaulha...@gmail.com wrote: Yup, I heard that the first time :-) It's

Re: new API webpage format

2009-12-07 Thread Tom Faulhaber
It turns out the doc string for filter was dropped during a checkin earlier this year. I surprised no one noticed sooner (I guess everyone just knows how filter works). I have filed ticket 219 with a patch and hopefully we'll get it into 1.1. I didn't see any others missing, have you seen

Re: new API webpage format

2009-12-07 Thread Tom Faulhaber
I like that too. I'll have to think about how we'd do that. On Dec 7, 8:11 pm, ataggart alex.tagg...@gmail.com wrote: While we're throwing requests at Tom, it'd be nice if the special forms were included in the api. On Dec 7, 5:21 pm, Tom Faulhaber tomfaulha...@gmail.com wrote: Yup, I

Re: Multiple dispatch with Multimethods

2009-12-07 Thread Tzach
Thanks I didn't know the costume hierarchy at all, it seems to be very useful. I understand it is coupled to the Java object hierarchy. Is there a way to create similar util for strings, as I did on my first example? On Dec 7, 12:10 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Dec 7,