Boggle solver

2009-11-07 Thread james
Hey! As a learning exercise I wrote a simple boggle solver in clojure. I'm sure there is lots of room for improvement to make it more idiomatic and perform better so I would be grateful if anyone would care to cast their eye over it. http://wiki.github.com/phraemer/Boggle-Solver thanks, James

Re: Code formatter

2009-11-07 Thread mudphone
Um, I use butterflies? On Nov 6, 5:35 pm, John Harrop wrote: > On Fri, Nov 6, 2009 at 7:41 PM, Tim Dysinger wrote: > > Use emacs! It formats your code while you type :) > > Nasty side effect though -- it formats your brain while you type, too. > Eventually you wind up a gibbering lunatic. :) I'

Re: clojure.xml/parse of XHTML yields a 503 on the DTD

2009-11-07 Thread Joubert Nel
Perhaps xml/parse shouldn't fetch the DTD, as per the W3C recommendation? On Nov 7, 2:46 am, Christophe Grand wrote: > The w3c filters traffic to DTDs, see here for more > details:http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic > > Christophe > > > > > > On Sat, Nov 7, 20

Re: newbie question

2009-11-07 Thread Christophe Grand
Can I play too? Non-lazy version (basically the same as Chouser's with reduce instead of loop): (defn partition-when [pred coll] (reduce #(if (pred %2) (conj %1 [%2]) (conj (pop %1) (conj (peek %1) %2))) [[]] coll)) user=> (partition-when odd? (range 1 15)

Avoiding reflection/hinting with byte-array.

2009-11-07 Thread David Brown
I can't figure out how to avoid reflection, in the 'update' method of MessageDigest. It is overloaded on a single argument with either 'byte', 'byte[]', or 'java.nio.ByteBuffer'. (import '(java.security MessageDigest)) (set! *warn-on-reflection* true) The compiler didn't seem to like a ta

Re: Avoiding reflection/hinting with byte-array.

2009-11-07 Thread Chouser
On Sat, Nov 7, 2009 at 10:41 AM, David Brown wrote: > > I can't figure out how to avoid reflection, in the 'update' method of > MessageDigest.  It is overloaded on a single argument with either > 'byte', 'byte[]', or 'java.nio.ByteBuffer'. > >   (import '(java.security MessageDigest)) >   (set! *

Re: clojure.xml/parse of XHTML yields a 503 on the DTD

2009-11-07 Thread Stefan Tilkov
On 07.11.2009, at 15:07, Joubert Nel wrote: > > Perhaps xml/parse shouldn't fetch the DTD, as per the W3C > recommendation? > It's highly likely it's the underlying Java parser that does so (even though it doesn't need to) - the same problem would be there if a Java program running in the sa

Re: ICFP Proposals

2009-11-07 Thread Dimitri Mallis
Thank you Tim, I certainly appreciate information like this! I am busy writing a paper for the IEEE conference later on in 2010. Its for my honours university work. Bluetooth social messaging and proximity related activities in and around the university campus. I have done a lot of work with JAV

web REPL

2009-11-07 Thread Mark Volkmann
A couple of months ago I saw a web site that provided a web-based REPL for many programming languages including Clojure. I can't find it now. Does anybody have that URL? -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ You received this message be

Re: Avoiding reflection/hinting with byte-array.

2009-11-07 Thread David Brown
On Sat, Nov 07, 2009 at 11:48:32AM -0500, Chouser wrote: >This should work: > >(defn update1 [#^MessageDigest md, #^bytes item] > (.update md item)) This does seem to work, thanks. Any reason that 'doubles' is also defined as an array cast function, but 'bytes' is not? David --~--~--

Re: Avoiding reflection/hinting with byte-array.

2009-11-07 Thread Chouser
On Sat, Nov 7, 2009 at 2:57 PM, David Brown wrote: > > On Sat, Nov 07, 2009 at 11:48:32AM -0500, Chouser wrote: > >>This should work: >> >>    (defn update1 [#^MessageDigest md, #^bytes item] >>      (.update md item)) > > This does seem to work, thanks. > > Any reason that 'doubles' is also defi

Re: web REPL

2009-11-07 Thread Chouser
On Sat, Nov 7, 2009 at 2:50 PM, Mark Volkmann wrote: > > A couple of months ago I saw a web site that provided a web-based REPL > for many programming languages including Clojure. I can't find it now. > Does anybody have that URL? Perhaps this one on Google AppEngine? http://lotrepls.appspot.co

Adding meta data to a function (from a macro)

2009-11-07 Thread Stefan Arentz
I'm trying to do this: (defmacro my-defn [name & body] `(defn- #^{ :foo-tag "blah" } ~name [] ~...@body)) The idea is that foo will be defined and that {:foo-tag "blah"} is added to its meta-data. But that does not seem to work: user> (my-defn foo (println "Hello")) #'user/foo use

Re: Adding meta data to a function (from a macro)

2009-11-07 Thread Alex Osborne
Stefan Arentz wrote: > > I'm trying to do this: > > (defmacro my-defn [name & body] >`(defn- #^{ :foo-tag "blah" } ~name [] > ~...@body)) > > The idea is that foo will be defined and that {:foo-tag "blah"} is > added to its meta-data. > > But that does not seem to work: Try this:

Re: Adding meta data to a function (from a macro)

2009-11-07 Thread Richard Newman
>> The idea is that foo will be defined and that {:foo-tag "blah"} is >> added to its meta-data. ... and to explain *why*: user=> (pprint (read-string "(defmacro my-defn [name & body] `(defn- #^{ :foo-tag \"blah\" } ~name [] ~...@body))")) (defmacro my-defn [name & body] (clojur

Functions and vars and meta-data

2009-11-07 Thread Stefan Arentz
Another one related to my previous question about meta-data. user> (defn #^{ :xxx 1} foo [] "foo") #'user/foo user> (defn #^{ :xxx 2} bar [] "bar") #'user/bar I need to do something similar to this: user> (map #(:xxx (meta %)) [foo bar]) (nil nil) Basically accessing the meta data of a functio

Re: Functions and vars and meta-data

2009-11-07 Thread John Harrop
On Sat, Nov 7, 2009 at 8:04 PM, Stefan Arentz wrote: > But I'm using this in a bigger macro that takes a bunch of functions > as a parameter. Is there a way to make this work or should I > 'translate' the functions that I take by name with (var foo)? You'll need to translate the symbols into va

Re: Functions and vars and meta-data

2009-11-07 Thread Stefan Arentz
On 2009-11-07, at 8:28 PM, John Harrop wrote: > On Sat, Nov 7, 2009 at 8:04 PM, Stefan Arentz > wrote: > But I'm using this in a bigger macro that takes a bunch of functions > as a parameter. Is there a way to make this work or should I > 'translate' the functions that I take by name with (va

Re: Functions and vars and meta-data

2009-11-07 Thread John Harrop
On Sat, Nov 7, 2009 at 8:34 PM, Stefan Arentz wrote: > On 2009-11-07, at 8:28 PM, John Harrop wrote: > > > On Sat, Nov 7, 2009 at 8:04 PM, Stefan Arentz > > wrote: > > But I'm using this in a bigger macro that takes a bunch of functions > > as a parameter. Is there a way to make this work or sho

Re: Functions and vars and meta-data

2009-11-07 Thread Alex Osborne
Stefan Arentz wrote: > I must admin that I don't fully understand the difference between foo > and #'foo. That is probably why I'm making this beginner mistake :-) The difference takes some explanation. So without further ado... Functions and Metadata: in Vivacious Gory Detail ==

Re: newbie question

2009-11-07 Thread Warren Wood
On Nov 6, 12:10 pm, John Harrop wrote: > On Fri, Nov 6, 2009 at 1:07 PM, John Harrop wrote: > > On Fri, Nov 6, 2009 at 1:01 PM, Warren Wood > > wrote: > > >> In the meantime, I came up with the following, which seems to work. > >> I'm sure it can be improved. > > >> (defn NOT [pred] (fn [x] (

Re: newbie question

2009-11-07 Thread Warren Wood
Thanks, that was indeed helpful! On Nov 6, 6:47 pm, Alex Osborne wrote: > Alex Osborne wrote: > > Like Mark's but using split-with instead of split-at: > > > (defn partition-when [pred coll] > >    (lazy-seq > >     (when-let [[x & xs] (seq coll)] > >       (let [[xs ys] (split-with (complement

Gensym collisions can be engineered.

2009-11-07 Thread John Harrop
user=> (def q 'G__723) #'user/q user=> (def r (gensym)) #'user/r user=> q G__723 user=> r G__723 user=> (= q r) true It's possible to anticipate the next gensym name that will be generated and then engineer a collision, and therefore possibly variable capture unintended by the author of a macro.

Re: newbie question

2009-11-07 Thread Warren Wood
Thought of this, which I like better. Again, I'm surprised if conjunction is not already a standard function, but I can't find it. I'm still a bit tempted to call it AND for readabilty of code. (I spent some time studying combinatory logic back in the day. (I even had a "Curry Fellowship" at Pe

Another "closure" available

2009-11-07 Thread Adrian Cuthbertson
Hmm, someone else has made another "closure" available :). http://googlecode.blogspot.com/2009/11/introducing-closure-tools.html -Adrian. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to t

Re: Another "closure" available

2009-11-07 Thread pmf
On Nov 8, 6:08 am, Adrian Cuthbertson wrote: > Hmm, someone else has made another "closure" available :). > > http://googlecode.blogspot.com/2009/11/introducing-closure-tools.html There's also Clozure Common Lisp [1], which is conceptually closer to Clojure. [1] http://www.clozure.com/clozurec