Re: shuffle vector in Clojure

2008-08-26 Thread Chouser
On Tue, Aug 26, 2008 at 11:54 PM, Shawn Hoover <[EMAIL PROTECTED]> wrote: > For one thing, it seems like there must be a cleaner way to handle > my use of reduce in test-shuffle-uniformity. I like reduce for > looping functionally, but in this case I just need to run n times > regardless of the sp

Re: Binding dynamically created symbols in the lexical context.

2008-08-26 Thread Chouser
On Sun, Aug 24, 2008 at 6:02 PM, budu <[EMAIL PROTECTED]> wrote: > > Well, for now only the value s used by the parser macro is really > needed. I think you misunderstood me, but I'm not too sure. Anyway, here's an attempt: (defn match-forms [p s] (if (= '_ p) [] (loop [p p s s vars []]

shuffle vector in Clojure

2008-08-26 Thread Shawn Hoover
I needed to shuffle a vector so I decided to try doing it functionally. Below is the implementation and a couple exercise functions, inspired by http://en.wikipedia.org/wiki/Fisher-Yates_shuffle and http://szeryf.wordpress.com/2007/06/19/a-simple-shuffle-that-proved-not-so-simple-after-all/ . A ve

Re: Greetings

2008-08-26 Thread Parth Malwankar
On Aug 26, 10:05 pm, noahr <[EMAIL PROTECTED]> wrote: > ps - any chance of getting a hold of that ant colony demo? http://clojure.googlegroups.com/web/ants.clj Parth --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Group

path: some more error info for "Don't know how to create ISeq from..."

2008-08-26 Thread Parth Malwankar
Hello, Attached is a patch to give a little more information for "java.lang.IllegalArgumentException: Don't know how to create ISeq from:" error. The current behavior is: user=> (map identity 1) java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer java.lang

Greetings

2008-08-26 Thread noahr
Hello everyone, Just wanted to report this language seems awesome. It's exactly the sort of thing I (and hopefully others) have been looking for. Very cool. I would offer feedback as a newbie, though, that more 'examples' spread throughout the primary docs, and more of a 'getting started w/ exam

First impressions

2008-08-26 Thread noahr
Some more first impressions from a newbie. The language is AWESOME, but here are some of the first specific questions I wondered about. 1) I found myself wanting to do an import *, though I understand this has been commented on already, and argued against. I'm not really arguing FOR it, but I th

Hello Clojure Servlet

2008-08-26 Thread Craig McDaniel
Here is a simple "hello world" servlet project that runs under Tomcat. It may be useful to others. Note: This code works with the 20080612 Clojure release, but doesn't seem to find the doGet method when using the current SVN release. *** Instructions *** 1. Edit build.properties in user home to

Re: executing shell command

2008-08-26 Thread John
I did this: (import '(java.io BufferedReader InputStreamReader)) (defn cmd [p] (.. Runtime getRuntime (exec (str p (defn cmdout [o] (let [r (BufferedReader. (.InputStreamReader. (.getInputStream o)))] (dorun (map println (line-seq r) Then: (cmdout (cm

Re: for collection, take consecutive pairs incrementing by one

2008-08-26 Thread John
Perfect! Thanks On Aug 25, 9:22 pm, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Aug 25, 9:16 pm, John <[EMAIL PROTECTED]> wrote: > > > For each element, get element and next element (incrementing index by > > one, not two), operate on the two, returning a new collection. > > There's the brute for

updating nested structure

2008-08-26 Thread Parth Malwankar
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 vector ; ... code listing after interaction user=> nx {:a {:b {:

Re: type of structure

2008-08-26 Thread Stuart Sierra
On Aug 25, 1:18 pm, Rich Hickey <[EMAIL PROTECTED]> wrote: > If I give you struct types, you'll next ask for struct derivation > > etc :) Long live Clojure, defender of the dynamic, protector of the functional, and arch-nemesis of static types! -Stuart --~--~-~--~~~---

Re: executing shell command

2008-08-26 Thread Stuart Sierra
Launching shell commands from Java is a nuisance. Commons Exec helps a little bit: http://commons.apache.org/exec/ -Stuart Sierra On Aug 25, 8:00 am, Parth Malwankar <[EMAIL PROTECTED]> wrote: > I want to run a shell command through Clojure > so I tried the following which doesn't work: > > user