Re: Newbie question about anonymous functions

2009-08-02 Thread samppi
Also, identity works too: #(identity "foo") ; equivalent to (fn [] "foo") On Aug 2, 10:04 am, Meikel Brandmeyer wrote: > Hi, > > Am 02.08.2009 um 17:56 schrieb Sean Devlin: > > > 1.  Use quote > > > #(quote "foo") > > For this approach I would recommend `do`: > > (let [x 5] #(quote x)) ; *meeep

Re: Idiomatic parsing of objects from several lines of a text file

2009-08-02 Thread David Plumpton
On Jul 31, 9:42 pm, Lau wrote: > Hey, > > I wanted to do something with Git and Qt, and the result was a project > which never really got off the ground. However its capable of reading > an entire Gitlog into a hash-map in the form {:hash > 129412849 :commit ..} > and so on. Ẃe used it at work to

Re: commute documentation detail

2009-08-02 Thread Rich Hickey
On Sun, Aug 2, 2009 at 8:54 PM, Mark Volkmann wrote: > > On Sun, Aug 2, 2009 at 5:45 PM, Rich Hickey wrote: >> >> On Sun, Aug 2, 2009 at 3:20 PM, Mark Volkmann >> wrote: >>> >>> The doc for commute says "At the commit point of the transaction, sets >>> the value of ref to be: >>> (apply fun most-

Re: commute documentation detail

2009-08-02 Thread Mark Volkmann
On Sun, Aug 2, 2009 at 5:45 PM, Rich Hickey wrote: > > On Sun, Aug 2, 2009 at 3:20 PM, Mark Volkmann > wrote: >> >> The doc for commute says "At the commit point of the transaction, sets >> the value of ref to be: >> (apply fun most-recently-committed-value-of-ref args)". >> >> Looking at the sou

Re: commute documentation detail

2009-08-02 Thread Rich Hickey
On Sun, Aug 2, 2009 at 3:20 PM, Mark Volkmann wrote: > > The doc for commute says "At the commit point of the transaction, sets > the value of ref to be: > (apply fun most-recently-committed-value-of-ref args)". > > Looking at the source code in LockingTransaction.java, that doesn't > seem to alwa

Re: commute documentation detail

2009-08-02 Thread Mark Volkmann
I've been thinking about this more. Suppose I do something like this. (def my-ref (ref 1)) (defn f1 [] (dosync (ref-set my-ref 10))) (defn f2 [] (dosync (ref-set my-ref 5) (commute my-ref #(inc % (let [t1 (Thread. f1) t2 (Thread. f2)] (.start t1) (.start t2) (.j

New Library for Berkeley DB

2009-08-02 Thread meb
Hey all, I couldn't find a good set of bindings that wrapped most of the BDB's features so I wrote my own. This library covers most of its basic feature, wrapping cursors, transactions, and key value functionality in more idiomatic clojure. You can check it out on http://bitbucket.org/mebaran/b

Re: Trampolined backtracking maze solver

2009-08-02 Thread John Harrop
On Sun, Aug 2, 2009 at 5:48 AM, James Sofra wrote: > (defn tile-in-bounds? [[x y] maze] > (let [h (count maze)] >(if (and (>= y 0) (>= x 0) (< y h)) > (if (< x (count (maze y))) >true (defn tile-in-bounds? [[x y] maze] (and (>= y 0) (>= x 0) (< y (count maze)) (< x (coun

Re: Idiomatic parsing of objects from several lines of a text file

2009-08-02 Thread David Plumpton
On Jul 31, 8:15 pm, Baishampayan Ghose wrote: > I think David is trying to solve the Github Contest problem > -http://contest.github.com/and not really trying to write a Git client > in Clojure :) Actually no, although that looks pretty fun. --~--~-~--~~~---~--~

commute documentation detail

2009-08-02 Thread Mark Volkmann
The doc for commute says "At the commit point of the transaction, sets the value of ref to be: (apply fun most-recently-committed-value-of-ref args)". Looking at the source code in LockingTransaction.java, that doesn't seem to always be the case. I see this: f.fn.applyTo(RT.cons(vals.get(ref), f.

OT: Breaking change in ClojureQL

2009-08-02 Thread Meikel Brandmeyer
Dear Clojurians, I'm sorry for abusing the list for this announcement, but we are lacking another information media at the moment. We decided to unify the argument order for all functions, in that (depending on the function) the query resp. the table is always first. Fortunately there was

Re: Newbie question about anonymous functions

2009-08-02 Thread Meikel Brandmeyer
Hi, Am 02.08.2009 um 17:56 schrieb Sean Devlin: 1. Use quote #(quote "foo") For this approach I would recommend `do`: (let [x 5] #(quote x)) ; *meeep* (let [x 5] #(do x)) Other than that I would recommend `constantly` in this case, because it carries the intention, while the #(do ..) look

Re: Newbie question about anonymous functions

2009-08-02 Thread Sean Devlin
There are two other ways to write (fn [x] "foo") 1. Use quote #(quote "foo") 2. Use the constantly function (constantly "foo") Both return a constant value. Sean On Aug 2, 7:47 am, Jarkko Oranen wrote: > Chad Harrington wrote: > > I have a newbie question about anonymous functions.  Why

Re: Newbie question about peepcode server "Address already in use error"

2009-08-02 Thread Nathan Lefler
Try either killing your Java process or changing the port you're binding on. Nathan On Sun, Aug 2, 2009 at 8:21 AM, Leotis buchanan wrote: > Guys, > > I going through the peepcode tutorial, I am trying to run the code shown > below, but I keep getting : > *Address already in > use > [Thrown cl

Re: Possible addition to swing-utils?

2009-08-02 Thread Jarkko Oranen
On Aug 2, 2:12 am, Meikel Brandmeyer wrote: > > (defmacro with-chosen-file >    "Opens a file chooser, binds the result the user chose to the given >    variable name and executes the body. In front of the body there might >    be two options given: > >      :directory is the initial directory sh

Re: Newbie question about peepcode server "Address already in use error"

2009-08-02 Thread Leotis buchanan
Guys, I going through the peepcode tutorial, I am trying to run the code shown below, but I keep getting : *Address already in use [Thrown class java.net.BindException] * I am using ubuntu, is there someway I can specify the bind address to fix this problem. Thanks (ns mire (:use [mire c

Re: Newbie question about anonymous functions

2009-08-02 Thread Jarkko Oranen
Chad Harrington wrote: > I have a newbie question about anonymous functions. Why does the first form > below work and the second form does not? > > user> ((fn [] "foo")) > "foo" > > user> (#("foo")) > ; Evaluation aborted. fn and #() are not interchangeable. In the first example, you simply retu

Trampolined backtracking maze solver

2009-08-02 Thread James Sofra
Hi all, I am new to functional programming and thought this might be interesting to others to see my approach to this kind a recursion problem. I found this problem hard to think through, does anyone have any suggestions for simpler solution to this type of problem? I needed a recursive backtrac

Re: Clojure without Rich Hickey

2009-08-02 Thread J Aaron Farr
On Sun 02 Aug 2009 10:24, Chouser wrote: > On Sat, Aug 1, 2009 at 6:22 PM, Vagif Verdi wrote: >> >> Since i'm using clojure in my business i got worried at a sudden >> thought what would happen to clojure if Rich calls it a day. > ... > However, I do think the community already has sufficient >

Newbie question about anonymous functions

2009-08-02 Thread Chad Harrington
I have a newbie question about anonymous functions. Why does the first form below work and the second form does not? user> ((fn [] "foo")) "foo" user> (#("foo")) ; Evaluation aborted. Thanks, Chad --~--~-~--~~~---~--~~ You received this message because you are

Re: Clojure without Rich Hickey

2009-08-02 Thread Lau
Hi group, This is an interesting discussion and perhaps not a bad one to dive into up front. Currently (as I see it) all major decision making comes straight from Rich - He decides which features to implement/extend and if they go into core or not. It would probably be a good idea to move in the