Re: updating nested structure

2008-08-27 Thread Parth Malwankar
On Aug 28, 8:13 am, Chouser <[EMAIL PROTECTED]> wrote: > On Wed, Aug 27, 2008 at 10:37 PM, Parth Malwankar > > <[EMAIL PROTECTED]> wrote: > > In case the access path were vectors the above could become: > > > (mk-get my-fridge (item-path :mango) :quantity) > > (mk-assoc my-fridge (item-path :man

Re: updating nested structure

2008-08-27 Thread Chouser
On Wed, Aug 27, 2008 at 10:37 PM, Parth Malwankar <[EMAIL PROTECTED]> wrote: > In case the access path were vectors the above could become: > > (mk-get my-fridge (item-path :mango) :quantity) > (mk-assoc my-fridge (item-path :mango) :quantity new-quantity) > > Much less noise. apply actually can

Re: Debugger paths... approaching debugging nirvana!

2008-08-27 Thread Eric Thorsen
Rich, I moved to the resource script model and all is well. Thanks! Eric On Aug 20, 12:06 am, Eric Thorsen <[EMAIL PROTECTED]> wrote: > Rich, > I made the following change/hack in the compiler (my local copy) for > the smap entry: >         String nspath = > currentNS().getName().getName().repl

Re: updating nested structure

2008-08-27 Thread Parth Malwankar
On Aug 28, 12:10 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > I posted a variant here: > > http://paste.lisp.org/display/65964 > Rich, It works very nicely. Thanks. Just one thought in case the functions args are still being decided on. Could we consider taking access path as a vector rather

Re: gen-class for jar file

2008-08-27 Thread Craig McDaniel
The "Hello Servlet" post from yesterday does that. On Aug 27, 4:56 pm, "Kevin Downey" <[EMAIL PROTECTED]> wrote: > I am interested in using the gen-class related stuff to generate a > class file to load and run my clojure code from a jar file. Does > anyone have any example code for this they can

gen-class for jar file

2008-08-27 Thread Kevin Downey
I am interested in using the gen-class related stuff to generate a class file to load and run my clojure code from a jar file. Does anyone have any example code for this they can share? -- The Mafia way is that we pursue larger goals under the guise of personal relationships. Fisheye --~--~---

Re: updating nested structure

2008-08-27 Thread Rich Hickey
On Aug 27, 4:39 am, Parth Malwankar <[EMAIL PROTECTED]> wrote: > On Aug 26, 8:25 pm, Parth Malwankar <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > In order to update fields in nested structures/maps easily > > I have created a macro 'field-write'. > > (defmacro field-write [st k v access

Re: shuffle vector in Clojure

2008-08-27 Thread Shawn Hoover
On Wed, Aug 27, 2008 at 6:59 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > While I appreciate the intellectual exercise (and would point you to > http://okmij.org/ftp/Haskell/perfect-shuffle.txt if you haven't seen > it), one of the nice things about Clojure is that you aren't trapped > without mut

Re: shuffle vector in Clojure

2008-08-27 Thread Shawn Hoover
On Wed, Aug 27, 2008 at 12:11 AM, Chouser <[EMAIL PROTECTED]> wrote: > > > You could simplify your reduce fn a bit by using merge-with: > Or even: > > (defn test-shuffle-uniformity > "Shuffles a 3-item collection n times, mapping each result to the number > of > times it's hit. If the distributi

Re: updating nested structure

2008-08-27 Thread Chouser
On Tue, Aug 26, 2008 at 11:25 AM, Parth Malwankar <[EMAIL PROTECTED]> wrote: > > In order to update fields in nested structures/maps easily > I have created a macro 'field-write'. It looks like this has come up on IRC a few weeks ago: http://clojure-log.n01se.net/date/2008-07-15.html#09:22 I had

Re: First impressions

2008-08-27 Thread Allen Rohner
> 3) On a super minor nit-picky note, I was surprised that some of the > '(pr ...)' ish methods didn't return the result of what they were > printing. One of the very first things I wanted to do was to wrap > another expression around (pr ..) for debugging purposes, but since it > didn't return i

Re: shuffle vector in Clojure

2008-08-27 Thread Rich Hickey
On Aug 26, 11:54 pm, "Shawn Hoover" <[EMAIL PROTECTED]> wrote: > I needed to shuffle a vector so I decided to try doing it functionally. > Below is the implementation and a couple exercise functions, inspired > byhttp://en.wikipedia.org/wiki/Fisher-Yates_shuffleandhttp://szeryf.wordpress.com/20

Re: updating nested structure

2008-08-27 Thread Graham Fawcett
On Wed, Aug 27, 2008 at 4:39 AM, Parth Malwankar <[EMAIL PROTECTED]> wrote: > After some more experimentation I found that the field-write > macro didn't work with access-specs like (vector :a :b :c) > ... I should have thought of that before. > > So I reimplemented field-read and field-write as f

Re: updating nested structure

2008-08-27 Thread Parth Malwankar
On Aug 26, 8:25 pm, Parth Malwankar <[EMAIL PROTECTED]> wrote: > Hello, > > In order to update fields in nested structures/maps easily > I have created a macro 'field-write'. >     (defmacro field-write [st k v access-spec] >       ; st=data, k=key to update, v=val to put, access-spec=access > v

Re: shuffle vector in Clojure

2008-08-27 Thread Chouser
> You could simplify your reduce fn a bit by using merge-with: Or even: (defn test-shuffle-uniformity "Shuffles a 3-item collection n times, mapping each result to the number of times it's hit. If the distribution isn't uniform we've let bias into the random numbers or the algorithm. Typica