Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Nico Kruger
On 4 September 2011 20:40, Dennis Haupt wrote: > > Am 04.09.2011 19:08, schrieb Justin Kramer: >> On Sunday, September 4, 2011 12:21:23 PM UTC-4, HamsterofDeath >> wrote: >> >> >> Some other comments: >> >> - Nested defns are not good. > > why? imo, nested function/method definitions are a tool to

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 06.09.2011 16:28, schrieb Meikel Brandmeyer (kotarak): > > Am Dienstag, 6. September 2011 15:57:16 UTC+2 schrieb Mark > Rathwell: > > You want an anonymous function: > > (fn [x] (= x 2)) > > or the equivalent shorthand form: > > #(= % 2) > > O

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > > or the equivalent shorthand form: > > #(= % 2) > should i ever write a bigger app with clojure, it will be filled with these. i like them. -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.14 (MingW32) Comment: Using GnuPG with Mozilla - http:

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Meikel Brandmeyer (kotarak)
Am Dienstag, 6. September 2011 15:57:16 UTC+2 schrieb Mark Rathwell: > > You want an anonymous function: > > (fn [x] (= x 2)) > > or the equivalent shorthand form: > > #(= % 2) > Or even more short-hand: #{2} (for all 2s not in #{nil false}) Scary. Sincerely Meikel -- You received this mess

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > It was not a syntax error. Your expression just had the wrong > return value. I don't see how an IDE could help here. > > by type inference. i don't know how far an ide could track the types in clojure since it's completely lacking any type ann

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Mark Rathwell
You want an anonymous function: (fn [x] (= x 2)) or the equivalent shorthand form: #(= % 2) Sent from my iPhone On Sep 6, 2011, at 9:35 AM, Dennis Haupt wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > figured it out, i the () were a bit messed up. the working code: > > (def op

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Stefan Kamphausen
Hi, On Tuesday, September 6, 2011 3:35:08 PM UTC+2, HamsterofDeath wrote: > > > (every? (= parameter player) currow > i'd like to write something like: > > do i have to define the function via letfn before, or is there a way > to do it nested in the code? > you can create a function anytime using

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 thx, that's what i figured out a moment ago. i am used to allknowing ides Am 06.09.2011 15:25, schrieb Stefan Kamphausen: > hi, > > why does clojure want to cast the result to IFn? > > > if I parse that correctly, you have two parens around the >

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 figured it out, i the () were a bit messed up. the working code: (def open 0) (def p1 1) (def p2 2) (def emptyfield [open open open open open open open open open]) (defn indexOf [x y] (+ x (* y 3))) (defn withmove [x,y,player,field] (assoc field (

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Stefan Kamphausen
hi, > why does clojure want to cast the result to IFn? > if I parse that correctly, you have two parens around the let-expression. That leads to Clojure evaluating the let-expression, taking the result (which is the return value of the line you mentioned: a Boolean) and trying to call that as

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-06 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 i tried using letfn insteaf of defn for inner functions. (def open 0) (def p1 1) (def p2 2) (def emptyfield [open open open open open open open open open]) (defn indexOf [x y] (+ x (* y 3))) (defn withmove [x,y,player,field] (assoc field (indexOf

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-04 Thread Eric Lavigne
> i started with a tic tac toe implementation, but i'm stuck: I used the same example problem last year to teach Clojure to two people that were new to programming. Hopefully you'll find their code helpful. https://github.com/algarete13/tic-tac-toe -- You received this message because you

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-04 Thread Sean Corfield
On Sun, Sep 4, 2011 at 11:40 AM, Dennis Haupt wrote: >> - 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 Right, but defn binds function names at the top-level (which is why it

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-04 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 04.09.2011 19:04, schrieb Luc Prefontaine: > Have a look at reduce: > > (reduce conj [] (take 9 (cycle [0]))) > > take returns a lazy seq. but reduce will return you a vector. > > Looks like you try to translate as if you were using a language >

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-04 Thread Dennis Haupt
-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

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-04 Thread Sergey Didenko
Dennis, may I suggest you to read this great article on Clojure: http://java.ociweb.com/mark/clojure/article.html -- 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 me

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-04 Thread 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 [mo

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-04 Thread Luc Prefontaine
Have a look at reduce: (reduce conj [] (take 9 (cycle [0]))) take returns a lazy seq. but reduce will return you a vector. Looks like you try to translate as if you were using a language that allows mutations but you use functions to hold values that you redefine since mutation is restricted t

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-04 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 solved my last problem, and now i'm stucker than before: (def open 0) (def p1 1) (def p2 2) (def emptyfield [open open open open open open open open open]) (defn updated [seq index replacement] (concat (take index seq) [replacement] (dr

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-04 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 i started with a tic tac toe implementation, but i'm stuck: (def open 0) (def p1 1) (def p2 2) (def emptyfield [open open open open open open open open open]) (defn updated [seq index replacement] (concat (take index seq) [replacement]

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-03 Thread Sergey Didenko
You can also put a commented out example call of the function, like this: (defn some-magic [spells wizards] ...) ; (some-magic 5 [:gendalf :einstein]) Which is also handy for quick evaluation in the REPL. Or you can put these example calls in the (automatic) test code. -- You received this mes

Re: coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-03 Thread Luc Prefontaine
On Sat, 3 Sep 2011 13:43:42 -0700 (PDT) HamsterofDeath wrote: > this might seem like a stupid question, but for me, not knowing the > type of something is like being stuck in a dead end for anything non > trivial. It's not stupid, it's normal :) In functional programming, most of the time you w

coming from statically typed oo languages - how do deal with complex objects graphs in clojure?

2011-09-03 Thread HamsterofDeath
this might seem like a stupid question, but for me, not knowing the type of something is like being stuck in a dead end for anything non trivial. i've made a few little experiments with clojure (not much, just testing some features) and i see how powerful clojure can be - for small to medium sized