On Sun, Jan 4, 2009 at 11:48 AM, Timothy Pratley
wrote:
>
> From a cursory examination of "literate programming" central tenants
> appear to be:
> (1) order by human logic
> (2) use descriptive macros
> (3) program is a web
>
> (1) Is not possible in Clojure because it resolves symbols as it read
On Sun, Jan 4, 2009 at 3:51 PM, Tom Ayerst wrote:
> I tidied up a couple of things:
> Changed function name 'verify-direction' to 'new-direction' (it is more than
> a simple verification)
Sounds good. I made that change to mine.
> Passed 'direction' and 'snake-head' to 'new-direction' to avoid
I tidied up a couple of things:
Changed function name 'verify-direction' to 'new-direction' (it is more than
a simple verification)
Passed 'direction' and 'snake-head' to 'new-direction' to avoid accessing
global state from inside the function
Used destructuring to simplify let statement in new-hea
>From a cursory examination of "literate programming" central tenants
appear to be:
(1) order by human logic
(2) use descriptive macros
(3) program is a web
(1) Is not possible in Clojure because it resolves symbols as it reads
them. However that is easy to work around with a trivial patch (see
h
On Jan 3, 10:14 am, "Mark Volkmann" wrote:
> What do you think of this way of resolving the issue? Note the use of the
> local variable "message". That can get set to either "You win!" or "You
> killed the snake!" inside dosync. Then outside dosync I check that and call
> new-game only if it's
My way was a little verbose, but you could do:
(defn verify-direction
"Gets the current snake direction or
a new one if a board edge was reached."
[]
(let [direction (@snake :direction)
head (snake-head)
x (head :x)
y (head :y)
at-left (= x 0)
at-r
On Sat, Jan 3, 2009 at 12:14 AM, Mark H. wrote:
>
> 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
>> ori
On Fri, Jan 2, 2009 at 9:31 PM, John Newman wrote:
> 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))
On Sat, Jan 3, 2009 at 3:03 AM, Brian Will wrote:
>
> The problem with the snake running off the edge simply is a flaw in
> your logic here:
>
> (defn verify-direction
> "Gets the current snake direction or
> a new one if a board edge was reached."
> []
> (let [direction (@snake :direction)
The problem with the snake running off the edge simply is a flaw in
your logic here:
(defn verify-direction
"Gets the current snake direction or
a new one if a board edge was reached."
[]
(let [direction (@snake :direction)
head (snake-head)
x (head :x)
y (head :y
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
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
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
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
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
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
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
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
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
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
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
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
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
>
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
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
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
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
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
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
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
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
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
32 matches
Mail list logo