Re: literate snake

2009-01-02 Thread Mark H.
On Jan 2, 5:39 pm, "Mark Volkmann" wrote: > For anyone still following this, the latest code that incorporates > many of the suggestions I've received here is > athttp://www.ociweb.com/mark/programming/ClojureSnake.html, replacing my > original version. It now uses refs. I think I have the dosyn

Re: Some code review for clj-record?

2009-01-02 Thread Brian Doyle
John, I was looking around at your tests just to get a feel for using the test-is stuff in the contrib library. I noticed that when I ran main.clj it would run not only the tests in clj-record, but all of the tests in the clojure.contrib as well. I was curious so I attempted to figure out what w

Re: detecting running as script

2009-01-02 Thread Timothy Pratley
Ah, another left field idea: if you test the namespace you will find running from REPL the namespace will be user running from the command will be clojure.core I'm certain that will work as I've tested it in the past. Bit of a hack, but should do the job. --~--~-~--~~~-

semi-structured program editing

2009-01-02 Thread falcon
http://www.cs.brown.edu/research/plt/software/divascheme/ or http://www.youtube.com/watch?v=GnQV4je9wTQ Just for some inspiration :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: literate snake

2009-01-02 Thread John Newman
I don't know much about functional programming, but I believe you're supposed to think about functions as black boxes. Put something in, get something out. Take this function, for example: (defn snake-head [] (first (@snake :body))) (We're cheating on the put something in part!) Perhaps it'd

Re: literate snake

2009-01-02 Thread Mark Volkmann
For anyone still following this, the latest code that incorporates many of the suggestions I've received here is at http://www.ociweb.com/mark/programming/ClojureSnake.html, replacing my original version. It now uses refs. I think I have the dosyncs optimally placed. Feedback still welcomed! Can I

Re: implementing the Hofstadter Male and Female sequences

2009-01-02 Thread Mark Engelberg
I don't think you need the declare line in your example, since the recursive references are inside of closures. I think your code is already very elegant, in the sense that it almost directly mirrors the mathematical definition of the sequences. There are probably ways to make it more efficient

Re: shelling out, convenience function for Runtime.exec()

2009-01-02 Thread Phil Hagelberg
Chouser writes: > I've added shell-out to clojure-contrib, with an 'sh' function that > allows usage like: This is great; I was wondering where such a function was a couple weeks ago. Thanks! -Phil --~--~-~--~~~---~--~~ You received this message because you ar

Re: literate snake

2009-01-02 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 5:40 PM, lpetit wrote: > > Hello, > > here are some feedbacks : > > I suggest you should create a namespace for the code of the game > ('cause you want to show clojure good coding practices, as well as > good coding conventions, won't you ;-) Right! Thanks for the suggesti

Re: literate snake

2009-01-02 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 5:29 PM, lpetit wrote: > > Yes, what you did should certainly be called "Intentional > programming" (or "Intention revealing programming") instead of > "literate programming". I was considering referring to "intentional" rather than "literate" until I saw this in the Wikip

Re: Java arrays caveat -- why?

2009-01-02 Thread Stuart Halloway
Java arrays are mutable. If you pass them around, everything in Clojure that relies on the assumption of immutability stops working. How big is your array? Does the Java API continue to hold on to it? Stuart >> From http://clojure.org/java_interop#toc27 : > > "Clojure supports the creation, r

Re: literate snake

2009-01-02 Thread lpetit
Hello, here are some feedbacks : I suggest you should create a namespace for the code of the game ('cause you want to show clojure good coding practices, as well as good coding conventions, won't you ;-) Could it make sense to use even fewer def's than currently ? I guess it could be made not m

Java arrays caveat -- why?

2009-01-02 Thread Hugh Winkler
>From http://clojure.org/java_interop#toc27 : "Clojure supports the creation, reading and modification of Java arrays. It is recommended that you limit use of arrays to interop with Java libraries that require them as arguments or use them as return values." What are the reasons for this caveat?

Re: literate snake

2009-01-02 Thread lpetit
Yes, what you did should certainly be called "Intentional programming" (or "Intention revealing programming") instead of "literate programming". This style of programming is for example encouraged by the book "Clean Code" of Robert C. Martin. I like this style of programming, I too think it is c

Re: clj-backtrace: more readable backtraces for Clojure

2009-01-02 Thread Mark McGranaghan
Hi Mike, Thanks for your interest. clj-backtrace is developed and tested against Clojure head, though it should work with reasonably recent versions of Clojure. I hope that you and other Clojure users have a chance to try it out in your environments and report the results back to the group. I wo

Re: literate snake

2009-01-02 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 4:48 PM, Chouser wrote: > > On Fri, Jan 2, 2009 at 5:20 PM, Mark Volkmann > wrote: >> >> On Fri, Jan 2, 2009 at 4:04 PM, Chouser wrote: >>> >>> I don't feel I have much authority in the realm of designing >>> concurrent programs, but here are a couple thoughts: >>> >>> I

Re: literate snake

2009-01-02 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 4:38 PM, Randall R Schulz wrote: > > On Friday 02 January 2009 14:23, Christian Vest Hansen wrote: >> What is it that makes this code "literate"? > > I don't know whether or not you're familiar with the concept of Literate > Programming. If you are, then you can judge for y

Re: literate snake

2009-01-02 Thread Chouser
On Fri, Jan 2, 2009 at 5:20 PM, Mark Volkmann wrote: > > On Fri, Jan 2, 2009 at 4:04 PM, Chouser wrote: >> >> I don't feel I have much authority in the realm of designing >> concurrent programs, but here are a couple thoughts: >> >> It seems to me that 'apple' and 'snake' together describe the s

Re: detecting running as script

2009-01-02 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 4:20 PM, Timothy Pratley wrote: > > I suspect that *command-line-arguments* would have "myapp.clj" as the > 0th element in the > clj myapp.clj > Can't test right now though sorry. Good idea! Unfortunately it seems that *command-line-args* is nil regardless of whether I loa

Re: literate snake

2009-01-02 Thread Randall R Schulz
On Friday 02 January 2009 14:23, Christian Vest Hansen wrote: > What is it that makes this code "literate"? I don't know whether or not you're familiar with the concept of Literate Programming. If you are, then you can judge for yourself whether that code qualifies as literate. If not, check ou

implementing the Hofstadter Male and Female sequences

2009-01-02 Thread Stuart Halloway
How would you implement the Hofstadter Male and Female sequences *elegantly* in Clojure? Here's a starting point: (declare h-male h-female) (defn h-male [n] (if (= n 0) 0 (- n (h-female (h-male (dec n)) (defn h-female [n] (if (= n 0) 1 (- n (h-male (

Re: literate snake

2009-01-02 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 4:23 PM, Christian Vest Hansen wrote: > > What is it that makes this code "literate"? Perhaps my understanding of the term is a bit off. What makes this code different from most Clojure code I see is that the functions tend to be very short and focused. I think this makes

Re: literate snake

2009-01-02 Thread Christian Vest Hansen
What is it that makes this code "literate"? On Fri, Jan 2, 2009 at 8:07 PM, Mark Volkmann wrote: > > I've written a new version of the snake program that uses a more > literate style and therefore, to my eyes, calls for far fewer > comments. I think this code is very readable. Check it out at >

Re: detecting running as script

2009-01-02 Thread Timothy Pratley
I suspect that *command-line-arguments* would have "myapp.clj" as the 0th element in the clj myapp.clj Can't test right now though sorry. On Jan 3, 3:34 am, "Mark Volkmann" wrote: > I have a file of Clojure code that I'd like to experiment with in the > REPL. I use (load file-path) to do that a

Re: literate snake

2009-01-02 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 4:04 PM, Chouser wrote: > > n Fri, Jan 2, 2009 at 4:47 PM, Mark Volkmann > wrote: >> >> On Fri, Jan 2, 2009 at 3:09 PM, Chouser wrote: >>> >>> On Fri, Jan 2, 2009 at 4:05 PM, Tom Ayerst wrote: That def inside a function doesn't look right but I'm a noob at this too

Debian/Ubuntu clojure package

2009-01-02 Thread Peter Collingbourne
Hello, I have recently put together a Debian package for clojure. The package may also work on Ubuntu however this is untested. It may be downloaded from: http://www.pcc.me.uk/~peter/debian/clojure_0.0.20081217-1_all.deb You may also be interested in the "source package" which is downloadabl

Re: literate snake

2009-01-02 Thread Chouser
n Fri, Jan 2, 2009 at 4:47 PM, Mark Volkmann wrote: > > On Fri, Jan 2, 2009 at 3:09 PM, Chouser wrote: >> >> On Fri, Jan 2, 2009 at 4:05 PM, Tom Ayerst wrote: >>> That def inside a function doesn't look right but I'm a noob at this too. I >>> managed to run the snake off the board which sugges

Re: literate snake

2009-01-02 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 3:08 PM, Tom Ayerst wrote: > Also; I think the 'get' is necessary on the get-snake-head and > get-snake-body. I assume you meant that "get-" is NOT necessary. I considered that, but I wanted the names of my functions that were not predicates to be verb-like. For example, t

Re: literate snake

2009-01-02 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 3:05 PM, Tom Ayerst wrote: > That def inside a function doesn't look right but I'm a noob at this too. I > managed to run the snake off the board which suggests the concurrency is not > quite right. Interesting. I can't duplicate that. > I would use 'cell' instead of 'gr

Re: literate snake

2009-01-02 Thread Mark Volkmann
On Fri, Jan 2, 2009 at 3:09 PM, Chouser wrote: > > On Fri, Jan 2, 2009 at 4:05 PM, Tom Ayerst wrote: >> That def inside a function doesn't look right but I'm a noob at this too. I >> managed to run the snake off the board which suggests the concurrency is not >> quite right. > > Calling 'def' t

Re: clj-backtrace: more readable backtraces for Clojure

2009-01-02 Thread Michael Reid
Hi, I don't have Clojure in front of me right now to try this out, but from the looks of the README let me be the first to give you an emphatic *Thank you*. This is looking rather useful. Nice work. My one concern with this is how brittle is this with respect to Clojure's development? Have you

Re: literate snake

2009-01-02 Thread Chouser
On Fri, Jan 2, 2009 at 4:05 PM, Tom Ayerst wrote: > That def inside a function doesn't look right but I'm a noob at this too. I > managed to run the snake off the board which suggests the concurrency is not > quite right. Calling 'def' to like this is much worse than a lack of comments, especia

Re: literate snake

2009-01-02 Thread Tom Ayerst
Also; I think the 'get' is necessary on the get-snake-head and get-snake-body. 2009/1/2 Tom Ayerst > That def inside a function doesn't look right but I'm a noob at this too. > I managed to run the snake off the board which suggests the concurrency is > not quite right. > > I would use 'cell' in

Re: literate snake

2009-01-02 Thread Tom Ayerst
That def inside a function doesn't look right but I'm a noob at this too. I managed to run the snake off the board which suggests the concurrency is not quite right. I would use 'cell' instead of 'grid'. Cheers Tom 2009/1/2 Mark Volkmann > > I've written a new version of the snake program th

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Justin Johnson
I found the cause of the second problem. All of the backslashes needed to be escaped. I tried a manual setlocal and then the value of complete didn't have any backslashes. It works if I escape the backslashes or if I use forward slashes though. So if I can change the code to just use forward sl

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Meikel Brandmeyer
Hi, Am 02.01.2009 um 21:06 schrieb Justin Johnson: I reinstalled Vim to C:\Vim and reinstalled VimClojure as well. This time I don't get the errors while opening a .clj file, but completion still is not working. Control-N completes things based on what's already in my file but not using anyth

Re: literate snake

2009-01-02 Thread Mark H.
On Jan 2, 11:07 am, "Mark Volkmann" wrote: > The most controversial thing about this code is probably my use of def > to change the state of the snake and the apple. It's not yet clear to > me that using atoms is needed here, but I need to think about that > more. Not atoms, refs. Or agents for

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Justin Johnson
I reinstalled Vim to C:\Vim and reinstalled VimClojure as well. This time I don't get the errors while opening a .clj file, but completion still is not working. Control-N completes things based on what's already in my file but not using anything from Clojure. Am I doing something wrong, or is it

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Justin Johnson
It looks like my change below just got rid of the errors. However the completion functionality is not working. :( On Fri, Jan 2, 2009 at 1:13 PM, Justin Johnson wrote: > I got it working by adding double quotes around the path, as can be seen in > the "let" line of the function below. > > funct

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Justin Johnson
I got it working by adding double quotes around the path, as can be seen in the "let" line of the function below. function! vimclojure#AddCompletions(ns) let completions = split(globpath("\"" . &rtp, "ftplugin/clojure/completions-" . a:ns . ".txt\""), '\n') if completions != [] cal

literate snake

2009-01-02 Thread Mark Volkmann
I've written a new version of the snake program that uses a more literate style and therefore, to my eyes, calls for far fewer comments. I think this code is very readable. Check it out at http://www.ociweb.com/mark/programming/ClojureLiterateSnake.html. Feedback is welcomed! The most controversi

Re: What is this function called?

2009-01-02 Thread lpetit
I don't know if the function exists on its own in Common Lisp, but in Common Lisp there is maplist that does what you get by combining map and rests : http://www.lispworks.com/documentation/HyperSpec/Body/f_mapc_.htm HTH, -- Laurent On Jan 2, 7:21 pm, "Andrew Baine" wrote: > On Fri, Jan 2, 200

Re: update-values for clojure.contrib.sql

2009-01-02 Thread budu
D'oh! I have a hard time kicking out that old habit. And changing code after testing it too! On Jan 2, 4:21 am, "Christian Vest Hansen" wrote: > Well, one thing that sticks out (particularly to me) is the fact that > you forgot to put your doc-string *before* your [params*] list :) > (ahem) > >

Re: Compilation problems

2009-01-02 Thread Rayne
On Jan 2, 11:27 am, "Stephen C. Gilardi" wrote: > On Jan 2, 2009, at 11:51 AM, Rayne wrote: > > > I checked, and the classpath (compile-path) is the "classes" directory > > in my clojure folder, so I put the file in there, and tried to compile > > it, it gave me > > You'll need to learn a bit a

Re: What is this function called?

2009-01-02 Thread Andrew Baine
On Fri, Jan 2, 2009 at 8:09 AM, Perry Trolard wrote: > > I did something similar using (iterate rest coll), which I called iter- > rest: > > (defn iter-rest > "Takes the first (count coll) items from call to (iterate rest > coll). > If passed function as first argument, calls it on each invoc

Re: macro trouble

2009-01-02 Thread Eric Tschetter
> From the Repl try: (.printStackTrace *e) Thanks! >> The thing is, I want to store the actual *function* not the symbol >> referencing the function (the symbol's reference changes after the >> macro is evaluated). > > 1:10 user=> (defmacro tracefn > "Creates trace logging of calls to a functio

How to interpret nested back quote in Macro?

2009-01-02 Thread wubbie
Hi all, Here is the code from Stu's CL translation. (defmacro check [& forms] `(do ~@(map (fn [f] `(report-result ~f '~f)) forms))) And report-result is: (defn report-result [result form] (println (format "%s: %s" (if result "pass" "FAIL") (pr-str form An example run is: (chec

Re: macro trouble

2009-01-02 Thread Meikel Brandmeyer
Hi, Am 02.01.2009 um 18:00 schrieb Eric Tschetter: From the Repl try: (.printStackTrace *e) The thing is, I want to store the actual *function* not the symbol referencing the function (the symbol's reference changes after the macro is evaluated). 1:10 user=> (defmacro tracefn "Creates trac

Re: Compilation problems

2009-01-02 Thread Stephen C. Gilardi
On Jan 2, 2009, at 11:51 AM, Rayne wrote: I checked, and the classpath (compile-path) is the "classes" directory in my clojure folder, so I put the file in there, and tried to compile it, it gave me You'll need to learn a bit about Classpath to work with Clojure. Basically, Classpath is a l

Re: Compilation problems

2009-01-02 Thread Rayne
On Jan 2, 11:02 am, Meikel Brandmeyer wrote: > Hi, > > Am 02.01.2009 um 17:37 schrieb Rayne: > > > The compilation produced 2 different class files, > > but it gave me a class not found error saying it couldn't find rayne > > $_main__32.class. It produced the class files, but gave me an error..

Re: Compilation problems

2009-01-02 Thread Meikel Brandmeyer
Hi, Am 02.01.2009 um 17:37 schrieb Rayne: The compilation produced 2 different class files, but it gave me a class not found error saying it couldn't find rayne $_main__32.class. It produced the class files, but gave me an error.. O_o. I'm on a windows vista PC by the way, thanks. Make sure t

Re: macro trouble

2009-01-02 Thread Eric Tschetter
> When you look at the backtrace of the exception you will find > (very far down the trace) lines like "caused by..". There you > normally find more useful information than "ExceptionInInitializer". I don't get a backtrace, all I get is what I put in the original message. How do I turn on full b

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Meikel Brandmeyer
Hi Justin, Am 02.01.2009 um 17:00 schrieb Justin Johnson: E539: Illegal character : complete+=kC:\Program\ Files\Vim \vimfiles\ftplugin\clojure\completions-clojure.core.txt The problem is the space in "Program Files". I'm not sure, whether this can be fixed at all on my side, or whether this

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Chouser
On Thu, Jan 1, 2009 at 11:23 AM, Meikel Brandmeyer wrote: > a long overdue release of VimClojure is available. Thanks, works great! --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To pos

Re: Compilation problems

2009-01-02 Thread Rayne
On Jan 2, 10:44 am, "Stephen C. Gilardi" wrote: > On Jan 2, 2009, at 11:37 AM, Rayne wrote: > > > into a file called rayne.clj and started it clojure, and typed > > (compile 'rayne). The compilation produced 2 different class files, > > but it gave me a class not found error saying it couldn't

Re: Compilation problems

2009-01-02 Thread Stephen C. Gilardi
On Jan 2, 2009, at 11:37 AM, Rayne wrote: into a file called rayne.clj and started it clojure, and typed (compile 'rayne). The compilation produced 2 different class files, but it gave me a class not found error saying it couldn't find rayne $_main__32.class. It produced the class files, but ga

Compilation problems

2009-01-02 Thread Rayne
I already made a post about problems compiling with emacs, but I suppose I'm the only one whos having this problem and no one knows how to fix it. I was testing out compilation into class files with clojure a little while ago. I put (ns rayne (:gen-class)) (defn -main [& args] (println("HI"))) i

detecting running as script

2009-01-02 Thread Mark Volkmann
I have a file of Clojure code that I'd like to experiment with in the REPL. I use (load file-path) to do that and then I can try out the functions it defines. At the bottom of the file it calls the functions required to run my application. Is there a way I can write the code so it only runs my app

Re: What is this function called?

2009-01-02 Thread Perry Trolard
I did something similar using (iterate rest coll), which I called iter- rest: (defn iter-rest "Takes the first (count coll) items from call to (iterate rest coll). If passed function as first argument, calls it on each invocation of rest, i.e. (iterate #(func (rest %)) coll)." ([coll]

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Justin Johnson
Hi Meikel, I am running Vim 7.2 on Windows XP and am not able to get the completion working in VimClojure. I get errors when trying to edit a .clj file. These errors always occur unless I comment out the code in clojure.vim that adds the completions. The errors I'm getting with VimClojure 1.3.0

Re: reduction

2009-01-02 Thread Chouser
On Dec 12 2008, 3:35 pm, Christophe Grand wrote: > I was sure it was a job for iterate: > > (defn reductions >   "Returns a lazy seq of the intermediate values of the reduction (as >   per reduce) of coll by f, starting with init." >   ([f coll] >    (if (seq coll) >      (for [s (iterate (fn [[x

Re: What is this function called?

2009-01-02 Thread Graham Fawcett
On Thu, Jan 1, 2009 at 10:14 PM, Andrew Baine wrote: > I want to get a seq of successive rests of the given seq: > user> (defn f [seq] > (if (empty? seq) > nil > (lazy-cons seq (f (rest seq) > #'user/f > user> (f '(1 2 3 4)) > ((1 2 3 4) (2 3 4) (3 4) (4)) Hi, Haskell has "tails" in the D

Re: What is this function called?

2009-01-02 Thread Chouser
On Thu, Jan 1, 2009 at 10:14 PM, Andrew Baine wrote: > I want to get a seq of successive rests of the given seq: > user> (defn f [seq] > (if (empty? seq) > nil > (lazy-cons seq (f (rest seq) > #'user/f > user> (f '(1 2 3 4)) > ((1 2 3 4) (2 3 4) (3 4) (4)) That's very similar to "tails" in

Re: Patch: Large negative range overflows

2009-01-02 Thread Olov Lassus
Issue 29 created with patch attached: http://code.google.com/p/clojure/issues/detail?id=29 On Dec 14 2008, 1:29 am, Olov Lassus wrote: > Hi, > Here's another patch from me: > > The clojure.lang.Range type is implemented with integer type start and   > end indices. The core.clj range function sh

Re: Patch: Detect overflow in IntegerOps.Negate

2009-01-02 Thread Olov Lassus
Issue 28 created with patch attached: http://code.google.com/p/clojure/issues/detail?id=28 On Dec 14 2008, 12:42 am, Olov Lassus wrote: > Hi, > thanks for Clojure! Here's my first contribution (CA filled out and   > will arrive next week): > > Negating Integer.MIN_VALUE overflows but should ret

Re: macro trouble

2009-01-02 Thread Meikel Brandmeyer
Hi again, Am 02.01.2009 um 03:37 schrieb Eric Tschetter: user=> (defmacro tracefn [function-name] "Creates trace logging of calls to a function." And another minor issue: the docstring goes in front of the argument vector, because Clojure allows also variable arity. (defn foo "doc

Re: macro trouble

2009-01-02 Thread Meikel Brandmeyer
Hi, Am 02.01.2009 um 03:37 schrieb Eric Tschetter: When you look at the backtrace of the exception you will find (very far down the trace) lines like "caused by..". There you normally find more useful information than "ExceptionInInitializer". user=> (defmacro tracefn [function-name] "Creates

Re: update-values for clojure.contrib.sql

2009-01-02 Thread Christian Vest Hansen
Well, one thing that sticks out (particularly to me) is the fact that you forgot to put your doc-string *before* your [params*] list :) (ahem) On Fri, Jan 2, 2009 at 8:21 AM, budu wrote: > > Hi, I was experimenting with clojure-contrib's sql features and found > that there wasn't any update-valu

Re: New library: BigInteger random numbers & other PRNG utils

2009-01-02 Thread Mark H.
On Jan 2, 12:46 am, "Mark H." wrote: > I've written a pseudorandom number generator for arbitrarily large > integers, as well as a number of other utilities for pseudorandom > numbers.   Other features: * Function to generate a random seed, using either Java's SecureRandom or your own entropy s

New library: BigInteger random numbers & other PRNG utils

2009-01-02 Thread Mark H.
I've written a pseudorandom number generator for arbitrarily large integers, as well as a number of other utilities for pseudorandom numbers. Features: * Everything is a lazy seq * Gaussian (mean 0, variance 1) - pseudorandom doubles * Arbitrarily large pseudorandom uniformly distributed integer