-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 04.09.2011 19:08, schrieb Justin Kramer:
> On Sunday, September 4, 2011 12:21:23 PM UTC-4, HamsterofDeath
> wrote:
> 
> * in the last loop where i am just printing out what i want to do,
> i need something like "foldLeft" (from scala). how do i fold in
> clojure?
> 
> doseq is the way to iterate over a collection and perform side
> effects:
> 
> (let [moves [[0 0 p1] [1 0 p1] [2 0 p1]]] (doseq [[x y player]
> moves]

nice shortcut

> (println "player" player "makes move at" x "/" y)))
> 
> reduce performs a left fold in Clojure.
> 
> * is there no predefined "updated" function?
> 
> Not for sequential data structures. It exists for associative
> structures like maps and vectors:
> 
> (assoc [:x :x :x] 1 :o) => [:x :o :x]



> 
> Some other comments:
> 
> - Nested defns are not good.

why? imo, nested function/method definitions are a tool to fine-tune
accessibility. just like public/private, but much more powerful. why
shouldn't i use that? why make everything flat and confuse the next
guy who's trying to figure out which def is supposed to be used by him
and which is a helper function?

You generally only want defs at the
> top-level. To create lexically-scoped helper functions within
> other functions, use let or letfn.
> 
> - Development (and debugging)

how to debug at all? using my ide debugger only shows "thing" i can
hardly apply to the code i wrote.

is usually easier when your program
> consists of small, testable functions. Your winner function is a
> bit hard to decipher. Consider factoring out functions that check
> for runs of a value across rows/columns.

again, why? the functions belong there, and nowhere else. they do not
make sense outside the winner-function. they use parameters which are
in scope there. factoring them out would actually make them more
complex since i would have to add more parameters to their signatures.

> 
> - I recommend reading up on Clojure's basic data structures (list, 
> vector, hash-map, set) and get familiar with how to build and
> manipulate them:
> 
> http://clojure.org/data_structures 
> http://blip.tv/clojure/clojure-data-structures-part-1-714056 
> http://java.ociweb.com/mark/clojure/article.html 
> http://4clojure.com/problems
> 

thx

> Justin
> 
> -- You received this message because you are subscribed to the
> Google Groups "Clojure" group. To post to this group, send email to
> clojure@googlegroups.com Note that posts from new members are
> moderated - please be patient with your first post. To unsubscribe
> from this group, send email to 
> clojure+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/clojure?hl=en


- -- 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOY8YrAAoJENRtux+h35aG+BEP/0IxG0pkx1Wu8IGR9Ku4HS8J
k4Ey+wVCRv+kf1eWo7nBHG3u5ny+WCdJmyWqG12AZw+7kTZGrE5jJKICvuY3ZyhH
VQb/DZzsnftJ8gEw8MzgnaLE3co7+QaCHYOqQP7g650z8AJboJh02SufGR1vk7VI
n7xaYraL25VykZ11Z321tqxJb1axjtIJMJT+hozHzcTUbmilXfj9qq6wr/9xmizK
lzDOkot2fxuqd5cPUs7WashCCy4lQQJlRr7mqTG87IZ2MV4lBjfvGQcFzT1Ue1gD
xA9OyCuDagdkpWwgyAfGblUTZM4L5eUzCgoo+ujfWu/oAsATX3tsKPBcAnJRr50v
lEqUjoCszK8iRSz35cRDOwKApVhXA/NVy05s16T7gnOVljItL9fthkJ4wsW3Wyf8
4jPXz7zFe/3sXDHJZe4EUkXvkzZRuJOSKk0s52ADIg/liApOHDwTSWt1ggnpjdfF
hn1iXmWftiVp2wFLgQLDdHZJeBt9Ok2ZsXolfueIEZnFPPreHB+UISiKYaMZ4GxK
MWypoqazyLp+FhFLyDzrMOynhxJsemLErEaJdgnF6hZJZmO91OgbAx6P7ZqmYDZe
e2IH/qEpkXCIxjU6YdNDHdTYGFCPOdKd7HAwiKtgO9Y5ubdjjoaksnKytSQqchjV
iA45lFtv8WaRCV+drlF0
=DoGC
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to