Re: anyone interested in a small game?

2011-10-31 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

seems to be pretty similar to asteriods. we can just do an engine that
can do both. at the same time.

does clojure support remote agents?


Am 31.10.2011 12:41, schrieb Timothy Baldridge:
 I'd be up for something like this. I have a fair amount of clojure 
 experience, and I've done quite allot of work with OpenGL in other 
 languages, so this actually sounds fun! Another option to consider,
 is the old DOS version of SpaceWar!
 
 http://www.youtube.com/watch?v=yY5qHe2VadA
 
 I like the idea of doing a Asteroids/Spacewar! clone, mostly
 because it would give us a chance to introduce Agents as the
 building block of the game engine.
 
 Timothy
 
 On Sun, Oct 30, 2011 at 1:32 PM, Dennis Haupt
 d.haup...@googlemail.com wrote: hi community,
 
 i decided to create a (small) game in clojure to get a bit of 
 non-theoretical experience. i'm pretty much a clojure noob (only
 did a few experiments) but have done a few real things in scala -
 which is totally awesome btw - so i do have some functional
 programming experience.
 
 if there's someone here who would like to join, just do so by 
 answering yes or something like that.
 
 i was thinking about a game like asteroids, tower defense or that
 old game with lots of aliens on the top and two players at the
 bottom, shooting upwards.
 
 
 
 
 -- 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/

iQIcBAEBAgAGBQJOrpI5AAoJENRtux+h35aG4TYQAI/fKfaddP0UAotFk44WekQs
joW3ea7v84rcg6qsCgQe0by0Zsa+oYP2nlQ4lneTu9VT4JQHC3MpLesRVYQ3qLQv
7VrBvuifLb84UeHWZhlYflMApVDr0l200anaHEhXbgxbG38MR0oBsAVg6wP5gx6a
TW17BSAIPEmu4XqMQxD9yYJvJMoMsKwDrA2Yguj7/hgJh3znNlADZZ6JVqKMv6h3
IyyYkDaYBJNAAhZiEm8zV1BVgzA6Lyh/IgBCWg2/o2oq4OkcjL2UBd2suvRO/gVS
24bBJoPHn+w2XVaplBWsxF/lEPnogOo9CeK5MOnaTVIA2Jq0e6cCnSM30OSsQ5UU
2kdnU6dOZ6VNocfL80T5b2eFvTjQKU6k3GIPV03FP6LxvRT8g/y5qqecTYlBW7G2
KJXY0Xw7otHQcaQxQD4kF//FCyim2+bQj5i//MhKzeMGRLr6CE8fSgov2nmwd6M8
yuCdip7bzOEsw2Bzr4iiC1dTp3pZhqLSIeDUJgFCI35argB4rai0RKne0eTly1fj
1jaQKddTY1mDrPKKsuKSwVAxFj6LeVHnBrdyzIr/9fEC/ccThIB8HoZmHbGU4jOZ
EwU9rCGNyd/lY1AcA6ou1MR2YY+MtlTmep7gczUHwelAsqbBxK3HS/2puPgQuOl+
8J+pEDcccpqAXRCKRSrp
=z8nu
-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


Re: anyone interested in a small game?

2011-10-31 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

isn't openGL a bit of overkill (we can just use java2d), or do you
want to add a renderer doing all sorts of awesome stuff which totally
contradicts the white-polygon-on-black-background graphics? might give
the game a pretty unique look :)

Am 31.10.2011 12:41, schrieb Timothy Baldridge:
 I'd be up for something like this. I have a fair amount of clojure 
 experience, and I've done quite allot of work with OpenGL in other 
 languages, so this actually sounds fun! Another option to consider,
 is the old DOS version of SpaceWar!
 
 http://www.youtube.com/watch?v=yY5qHe2VadA
 
 I like the idea of doing a Asteroids/Spacewar! clone, mostly
 because it would give us a chance to introduce Agents as the
 building block of the game engine.
 
 Timothy
 
 On Sun, Oct 30, 2011 at 1:32 PM, Dennis Haupt
 d.haup...@googlemail.com wrote: hi community,
 
 i decided to create a (small) game in clojure to get a bit of 
 non-theoretical experience. i'm pretty much a clojure noob (only
 did a few experiments) but have done a few real things in scala -
 which is totally awesome btw - so i do have some functional
 programming experience.
 
 if there's someone here who would like to join, just do so by 
 answering yes or something like that.
 
 i was thinking about a game like asteroids, tower defense or that
 old game with lots of aliens on the top and two players at the
 bottom, shooting upwards.
 
 
 
 
 -- 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/

iQIcBAEBAgAGBQJOrpwDAAoJENRtux+h35aGBx4P/RXFWjr+zFQMjA49bHobnOKY
PbepwqpwunucJ9M6zp0MDnudoXWDyE2zCG7QgAf/ZgaSoI4+4KvRL5IwYgPwBDO2
rgAEMSyK30/HLnSnn5zgTrFRRTNde2oCFMB5soE5qYNvRKB0lXJ58DbKHF3f21H9
NXPwz4x6GU1Vs1w9Kx94Skx+Rf4mJKX7sN6choI8ENOE8dEiXiyTFdqO1cNjPZyR
iimmEhaXzwjkHCcCPiLo1rTSn14yNty0EObNvo/WhFqK/4Y3YP7NR9tWrHJSN5ll
Sc4n9+B+qpaHrun+QvjIE41vXaMF3LPrXLRM9tM042ImRdvy210eVBU5h1riGA97
R/0c9fm6L4UbeuhS/SBVEg3m9bdL62dcxOmDcYi0kuYrNRRcBbioptEYCxiyhcmy
bna6/k6UZX+YeLNtvXBk49+K2fQElC3TIzEmIkotMd3Q0gjhhSsoYgcW3uCvWLy1
0RNSPSmKmQ9m6Htif/yO2dCnCVadO/nJgqeE8LsDMhtLlh8gj4Q+x3ppU6cxtiEP
S9mGISRv6Sk6p88TVHZGVKXEHLaRuhWrfC0Nu1mTQQEwm3ilQ10ipSLrnvlGfvBs
eqCqVJpXtx/m6cvtLLczB3WoKpsGvLhDJMq0TFxYMIKbws726YdpN/VRaEMSkGFm
YJWqDYGOPOubGge4tJbn
=JTgF
-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


Re: anyone interested in a small game?

2011-10-31 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

one agent per entity? i'd have done an agent for the whole world and
apply functions like apply-collision and apply-shot-fired to it

Am 31.10.2011 14:46, schrieb Timothy Baldridge:
 Haha! I forgot about Java2d... Yeah, that would work just fine.
 No, Clojure does not support remote agents. But agents can really
 help in a system like this to express objects as distinct entities.
 That is, you have one object per item on the screen, and then each
 object basically can live on its own:
 
 (send entity update-time timespan)
 
 (send asteroid do-split)
 
 etc.
 
 Actually, this really isn't too long of a project, at least the 
 asteroids part isn't.
 
 Timothy
 
 On Mon, Oct 31, 2011 at 8:00 AM, Dennis Haupt
 d.haup...@googlemail.com wrote: isn't openGL a bit of overkill
 (we can just use java2d), or do you want to add a renderer doing
 all sorts of awesome stuff which totally contradicts the
 white-polygon-on-black-background graphics? might give the game a
 pretty unique look :)
 
 Am 31.10.2011 12:41, schrieb Timothy Baldridge:
 I'd be up for something like this. I have a fair amount of
 clojure experience, and I've done quite allot of work with
 OpenGL in other languages, so this actually sounds fun!
 Another option to consider, is the old DOS version of
 SpaceWar!
 
 http://www.youtube.com/watch?v=yY5qHe2VadA
 
 I like the idea of doing a Asteroids/Spacewar! clone, mostly 
 because it would give us a chance to introduce Agents as the 
 building block of the game engine.
 
 Timothy
 
 On Sun, Oct 30, 2011 at 1:32 PM, Dennis Haupt 
 d.haup...@googlemail.com wrote: hi community,
 
 i decided to create a (small) game in clojure to get a bit
 of non-theoretical experience. i'm pretty much a clojure noob
 (only did a few experiments) but have done a few real things
 in scala - which is totally awesome btw - so i do have some
 functional programming experience.
 
 if there's someone here who would like to join, just do so
 by answering yes or something like that.
 
 i was thinking about a game like asteroids, tower defense or
 that old game with lots of aliens on the top and two players
 at the bottom, shooting upwards.
 
 
 
 
 -- 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
 
 
 
 
 
 
 -- 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/

iQIcBAEBAgAGBQJOrrKfAAoJENRtux+h35aG8xMP/RNYGqwEAXbuovpdI1KDyiny
fxUTQc+cppQwDNl43OwkdHlqlj7hHoWZVSshd5GoKjTBGGU/H6McILD0mKCvGUPw
EMOSDdzORPEJkQFc/VINGzBW3veQwAy/3K6TujwyO6ChsSCGbBepSABVvAtdUHpM
xU9CkSCu2s5iwxO25CrlsTliwV6xAAwUUkM0Rp7AR+qYco5msOPLBG0+KU/XVIPO
hqRX82SaqifPAbk2Yx4vRoR5wamF0w4vd0rRMVENMckImI3DteX1To+k3hHwCvLt
GJKyHwJXZRJ0JzBzUITjqfuVUI9pW+71RBh5odb13PuDNOpRou/k/JgDeTXK6e8t
l1BKpbchs+ar1IO38mlWSvsVwYDySuzkopBH1cSgOyAgUa1Yi/0HNSA05BgXxlyZ
voGnTGBjis/eLZ2Bdbz3EgITetxG/ypM41hlIj0QHEX6JWiAP9tCq7xvTLUVQ0a4
zzt+knoDOatQwbn+TgtcYyfl8ObtVrMJaQhpY5PnpdN3MDXFVqJpIZ8urm2UAn9w
35V+SiIV3/1UOAVaEdzmCLhDMPcHCuuB09rWZ7QpcywnomDyoGmURcog7hZX64hJ
OrhqBc1j39LmNwWO1cxSn9rPITsb8tozXt3VW5hIMXPWuIw2/uVla72PNl3jS7t8
OabAgU9XWOlNQOb5Vd/4
=FyCY
-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


{ANN} clojure-control 0.2.1 released.

2011-10-31 Thread dennis
Clojure-control is a clojure DSL for system admin and deployment with
many remote machines via ssh/rsync.It is on github:
https://github.com/killme2008/clojure-control

0.2.1 has been released,main highlights:
First,A shell command DSL by sunny87,for example:

(cd /home/login
(run ls)
(cd bin
(run ls)))

(cd /home/login
(path /home/login/bin
(env JAVA_OPTS -XMaxPermSize=128m
(run clojure

Second,Supports ssh/scp/rsync options when defining cluster,they can
be a string or a vector:

(defcluster :mycluster
  :ssh-options -p 44
  :scp-options -v
  :rsync-options [-arz --delete]
  :clients [
   { :host c.domain.com :user clogin :ssh-
options -v -p 43}
   ]
  :user login
  :addresses [a.domain.com b.domain.com])

Third, It supports executing task in parallel now,just define cluster
by
(defcluster :mycluster
  :parallel true
  )

At last, i recommend everyone try the lein-control plugin developed by
sunny87 for using cc much more simply,please visit
https://github.com/sunng87/lein-control

-- 
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


Re: anyone interested in a small game?

2011-10-31 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

i'm not looking for people to split the work and get things done
faster, i'm looking for people to think about how and why things
should be done.

for example, right now i have a record called gameentity which
contains a position, the current health, speed, the polygon
representation which should be rendered and a few more things - but
haven't figured out yet where to put the logic and how to apply it so
that everything is easily extensible





Am 31.10.2011 15:44, schrieb Timothy Baldridge:
 I once wrote a test game engine that handled used a one-agent per 
 entity approach, and the idea was that it should be close to 
 linearly scale-able. It actually worked quite well. I think in the
 end I tested it with more than 10,000 entities flying in a 
 flocking/following pattern, and the engine ran like a dream. IIRC
 the limit with 10,000 entities was more because my GPU on my laptop
 is crap, and couldn't push much more than that at a single time.
 With 10,000 entities on my quad-core desktop the app worked like a
 dream.
 
 Now all this is overkill for a small game, but it did seem to work 
 well. Unfortunately, I'm not sure a game as small as asteroids
 would work well to have multiple people working on it. Simply
 because each part of the game (graphics, physics, gui, etc.) are
 all so small, that multiple developers would just step on each
 other's toes.
 
 Timothy
 
 On Mon, Oct 31, 2011 at 9:37 AM, Dennis Haupt
 d.haup...@googlemail.com wrote: one agent per entity? i'd have
 done an agent for the whole world and apply functions like
 apply-collision and apply-shot-fired to it
 
 Am 31.10.2011 14:46, schrieb Timothy Baldridge:
 Haha! I forgot about Java2d... Yeah, that would work just
 fine. No, Clojure does not support remote agents. But agents
 can really help in a system like this to express objects as
 distinct entities. That is, you have one object per item on
 the screen, and then each object basically can live on its
 own:
 
 (send entity update-time timespan)
 
 (send asteroid do-split)
 
 etc.
 
 Actually, this really isn't too long of a project, at least
 the asteroids part isn't.
 
 Timothy
 
 On Mon, Oct 31, 2011 at 8:00 AM, Dennis Haupt 
 d.haup...@googlemail.com wrote: isn't openGL a bit of
 overkill (we can just use java2d), or do you want to add a
 renderer doing all sorts of awesome stuff which totally
 contradicts the white-polygon-on-black-background graphics?
 might give the game a pretty unique look :)
 
 Am 31.10.2011 12:41, schrieb Timothy Baldridge:
 I'd be up for something like this. I have a fair amount
 of clojure experience, and I've done quite allot of
 work with OpenGL in other languages, so this actually
 sounds fun! Another option to consider, is the old DOS
 version of SpaceWar!
 
 http://www.youtube.com/watch?v=yY5qHe2VadA
 
 I like the idea of doing a Asteroids/Spacewar! clone,
 mostly because it would give us a chance to introduce
 Agents as the building block of the game engine.
 
 Timothy
 
 On Sun, Oct 30, 2011 at 1:32 PM, Dennis Haupt 
 d.haup...@googlemail.com wrote: hi community,
 
 i decided to create a (small) game in clojure to get a
 bit of non-theoretical experience. i'm pretty much a
 clojure noob (only did a few experiments) but have done
 a few real things in scala - which is totally awesome
 btw - so i do have some functional programming
 experience.
 
 if there's someone here who would like to join, just do
 so by answering yes or something like that.
 
 i was thinking about a game like asteroids, tower
 defense or that old game with lots of aliens on the top
 and two players at the bottom, shooting upwards.
 
 
 
 
 -- 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
 
 
 
 
 
 
 -- 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
 
 
 
 
 
 
 -- 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

Re: anyone interested in a small game?

2011-10-31 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

no need for IRender since everything has a java.awt.polygon. i just
draw it. in a sense, the polygon is my IRender and it's data is the
implementation.

i was thinking about using a simple type (:asteroid, :ship, :bullet)
for each entity and pick an advance-function (input = complete old
game state + one specific entity, output = new entity) depending on it.
- -
{:asteroid advance-asteroid :ship advance-ship}

i'd like to avoid mutable states as much as possible which means there
will be one atom or agent for the whole world and a bufferedimage.
other than that, i'd like to stay purely functional.

Am 31.10.2011 19:03, schrieb Timothy Baldridge:
 In the OOP languages, entity systems seem to be all the rage. I 
 suggest stealing ideas from there if you can.
 
 
 In this same vein, I'd recommend thinking about the following
 approach:
 
 First, read up on reify and protocols. Next, create protocols for
 the main areas of your engine. Perhaps start with IRender and 
 IPhysicalEntity
 
 (defprotocol IRender (render [this]))
 
 (defprotocol IPhysicalEntity (update-position [this timespan]))
 
 
 
 then for the user ship, you can do something as simple as:
 
 (defn new-ship [x y] (let [pos (atom {:x x :y y})] (reify IRender 
 (render [this] (render-ship-model pos)) IPhysicalEntity 
 (update-position [this timespan] (swap! pos #(hash-map :x (inc (:x
 %)) :y (:y %)))
 
 there's bound to be errors in the above code, but you get the
 point. The thing I love about the above example is that we've
 completely abstracted away the parts of this engine. We can have
 entities that implement different protocols, we can have a separate
 data structure for each and every entity, depending on its needs,
 and everything is abstracted nicely. Static objects can just
 implement IRender, and invisible objects can implement
 IPhysicalEntity. Extend this to implement ICollideable (for
 collision detection), and you have the makings of a very extensible
 system.
 
 Timothy
 


- -- 

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

iQIcBAEBAgAGBQJOruwPAAoJENRtux+h35aG0NsP/3CmDZHPnWjIYS2wULzTE4cp
t9w+Citz3ZEfK5KmLDpy2dPB9l5bu2K4r7cwcgfmLLdZ90rcxgcan+WbtkffiPwd
RZdB/E6IJrVPd2RvTt858VjNYvIeWxeU4XhpgS9EUBjiqRurQHrVrV/5bKFudRGn
E8WO+wYv8kMGRxlB/3YjYxhxRtqy7Kevaf508J3Tq+U49TBnzpBYPvO8yX+HzRO2
RNDVOr4S1ANf4OPn0l7AETxnEcvsI5D359JwSMGQ5whSk60kveZXTsMiD6nCFsQ0
2CD57iGlhHisNF78gnT78x+Qi1aMmkzWl2adfeXrW/zqZLXghLHaWamEy9dETATY
TZxRlvYgqkp7Bwqh4+PHCB20uzRPTHex2bSw6SqY53XYiK8IWCG6iecwz0t/cuOt
BxWRn+uTOlgX8FPZqX954eMmu1/5QjNRje5+i8kS7naRuXeZQLxwgZt6uFHN8jTS
H4s2aso0eWyfimTQXgwQx1K+81LzbF+bDk2iI/6lk6sdbCoD1RkaIzp5qYJIxU4v
zmFInbt+tPQFHtl8taEoUavN/Vc8//evcBDQpfdZ32JhzmZUHqGeJXEHQuVFojSr
ursyF9oiCrWRlm4j63hWrYYdf6OUIzOYlzN2ehXGWt0Ek8TbV2J36XY8Jf6sPu3v
9LVXoiGlFmrjEtPKxog0
=8KV+
-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


Re: anyone interested in a small game?

2011-10-31 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

this is my opinion as well:
adding a layer of abstraction at a later point in time is much more
difficult than removing one that is just delegating calls, so it often
pays off to add one in the beginning just in case. i decided to just
skip that because everything is going to be a polygon, even lines and
circles can be represented as polygons.

i did what you suggested anyway.

Am 31.10.2011 20:03, schrieb Timothy Baldridge:
 As far as the mutable state goes, yes, that's probably a better
 route, at least for a simple game. However I would recommend
 against everything is a polygon route. Once again, for a simple
 game, this may be fine, but you're now making an assumption:
 everything is a polygon. What if you want a simple laser
 point-to-point entity? What if you want a planet that is
 represented by a circle? What if you want your ship to be a
 different color than the asteroids? By implementing IRender


, you get two side effects:
 
 1) you can now de-couple the presentation of the object, from the
 code that presents it 2) you can have very complex models (multiple
 polygons and colors) without having complex render code 3) you can
 have entities represented by bitmaps, polygons, circles, arcs, 3d
 meshes, etc.
 
 This is what Clojure excels at...de-coupling, or as Rich put it in
 his recent talk Simple made Easy: don't assume things about your
 code. Don't assume that all models will always fit into the concept
 of a polygon...don't assume that you'll always want to represent
 your models via Java2D.
 
 Now, I'm not saying that your idea is bad for a simple game...but
 for a larger project you may run into problems with this approach.
 
 If you want a good way to think about this, I'd recommend trying
 to design the engine to run on both Clojure and ClojureScript. Have
 it support Java2D, SVG and Canvas front ends...even if you don't 
 implement anything but the JVM version, if you can at least show
 that your engine would work on these other platforms without heavy 
 modifications (massive kodos if you can do this without any 
 modifications to the core engine at all) then I would say you have 
 reached a higher plane of understanding in when it comes to
 Clojure.



 
 Timothy
 
 
 
 On Mon, Oct 31, 2011 at 1:42 PM, Dennis Haupt
 d.haup...@googlemail.com wrote: no need for IRender since
 everything has a java.awt.polygon. i just draw it. in a sense, the
 polygon is my IRender and it's data is the implementation.
 
 i was thinking about using a simple type (:asteroid, :ship,
 :bullet) for each entity and pick an advance-function (input =
 complete old game state + one specific entity, output = new entity)
 depending on it. - {:asteroid advance-asteroid :ship
 advance-ship}
 
 i'd like to avoid mutable states as much as possible which means
 there will be one atom or agent for the whole world and a
 bufferedimage. other than that, i'd like to stay purely
 functional.
 
 Am 31.10.2011 19:03, schrieb Timothy Baldridge:
 In the OOP languages, entity systems seem to be all the
 rage. I suggest stealing ideas from there if you can.
 
 
 In this same vein, I'd recommend thinking about the
 following approach:
 
 First, read up on reify and protocols. Next, create protocols
 for the main areas of your engine. Perhaps start with IRender
 and IPhysicalEntity
 
 (defprotocol IRender (render [this]))
 
 (defprotocol IPhysicalEntity (update-position [this
 timespan]))
 
 
 
 then for the user ship, you can do something as simple as:
 
 (defn new-ship [x y] (let [pos (atom {:x x :y y})] (reify
 IRender (render [this] (render-ship-model pos))
 IPhysicalEntity (update-position [this timespan] (swap! pos
 #(hash-map :x (inc (:x %)) :y (:y %)))
 
 there's bound to be errors in the above code, but you get
 the point. The thing I love about the above example is that
 we've completely abstracted away the parts of this engine. We
 can have entities that implement different protocols, we can
 have a separate data structure for each and every entity,
 depending on its needs, and everything is abstracted nicely.
 Static objects can just implement IRender, and invisible
 objects can implement IPhysicalEntity. Extend this to
 implement ICollideable (for collision detection), and you
 have the makings of a very extensible system.
 
 Timothy
 
 
 
 
 -- 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/

iQIcBAEBAgAGBQJOrvt3AAoJENRtux+h35aGpaUP+wRIRAEckRC/QISuwCUzeYm8

Re: anyone interested in a small game?

2011-10-31 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

if you *really* make zero assumptions, every second call has to be a
protocol/interface call. *i know what i am, so no assumption* -
*interface call* - *repeat*

i think no assumptions should be make no assumptions about the
internals of what you are calling. as long as you just code against
the outer shell, you should be fine.

Am 31.10.2011 20:54, schrieb Michael Gardner:
 On Oct 31, 2011, at 2:03 PM, Timothy Baldridge wrote:
 
 This is what Clojure excels at...de-coupling, or as Rich put it
 in his recent talk Simple made Easy: don't assume things about
 your code. Don't assume that all models will always fit into the
 concept of a polygon...don't assume that you'll always want to
 represent your models via Java2D.
 
 It's impossible to make zero assumptions about your code; the trick
 is figuring out which are the appropriate ones. Making too many
 assumptions leads to brittle and hard-to-extend code, but making
 too few leads to over-generalized, ponderous code that does way
 more than it's ever likely to be used for.
 
 In a case like this game, it should be easy to refactor away from
 the everything is a polygon model if and when the game outgrows
 it, so I'd argue against introducing the extra complexity of
 per-entity renderers until it's actually necessary.
 
 That's a strength of dynamic, expressive languages like Clojure,
 IMO: because there's so much less code, refactoring is much easier.
 So instead of trying to predict all future requirements and
 possibly ending up with over-generalized code, you can make
 assumptions based on current/near-term requirements and refactor
 when those assumptions no longer apply.
 


- -- 

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

iQIcBAEBAgAGBQJOrwmYAAoJENRtux+h35aGTQgQAMC1bUbjN0Mz90fmOQVUCjBN
zO+UJXfaiVo6DmR0usZkv1ynwTyuZwQm+llhamabAMLUZXsIiAcbpu0KLjkxJwjJ
S6EpZwAsRnqYtUTn3DvdFC3kTkgUR5+KD7fQ97PBHBmyNKcy+GcU7MQP0bsZ9KdQ
26K6qo5TqWmkQEzvg9kVBrB2W5FQj6BuH7UA3LQxHSegpc4Wryxf9qQZFEa5mqFg
IdRUFFR2oLOD1rCBcVoeV9hvyPeIdw8ntHoVVepfeDN+PspC3Z58f09dr9E8gar6
Jp9DSgOsZr6ClUHVGUhVOaWPiFeZLunOe9cOCJTaanXKzkE1fejzuQez51sAo3ns
mSF40Ezip30kTpJWld1mQV4/mFgsmfymegQiJ71r8V0nEJxOESpmGPb3by0CIAyE
sqoFyh/oqbp8lwupwHI636L6O9DPqKYwIVv1ba0q09NhO6rbvDe93+9lWTs3n+XB
XLJprZjoU8A7PtUxCEdVCWx75Hi5Lt3FXaFeF/36clWCftRC9yyy+61ZAM5UrmsC
4QjUIG3jJCX7aeHteerWZrkApieYr5JBxL81Zyvf6at0wnINr/x8drWuB8R9gwKy
gBIpi+WrjSZhlCgkaQnJocgxrMhNTkdk1XsRcdHDFt1j5kLfb3ZdjK+rSr13XX0H
5FLhhzQZOnnlDibXw1P9
=nWrK
-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


Can't take value of a macro aka macro noob needs help

2011-10-30 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

i played around a bit

(defmacro times [times  exprs]
  '(let [countdown# ~times]
 (loop [remaining# countdown#]
   (when ( 0 remaining#)
 ~@exprs
 (recur (dec remaining#))

(defmacro forloop [[i end]  code]
  `(let [finish# ~end]
 (loop [~i 0]
   (when ( ~i finish#)
 ~@code
 (recur (inc ~i))

the second one works fine:
(forloop [a 4] (println a)

but when i try to do the loop without an externally applied counter
variable, i get a runtimeerror: Can't take value of a macro

what exactly does it mean? it also happend when using expandmacro, so
i guess my error is really, really obvious. but what is it?
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOrV29AAoJENRtux+h35aGEfAP/AjDZ7VpZOB7xg6xuhWfe0UO
pKH4WG5CDWF4MdezuWvS1n3D6V60cLV2DwdIS5K8TYBHnYKe6iKQwdpssNpDe4HE
3MwmYQIF8X4rbezH5XXhyR1WnWBAKJLrkTg1oB6SJNvUlotF8SnhjYTmROXX9sfV
OE+AiR0Mt8QoxKGnCBQOSDhAw0IMVdKpuAqTbfggUVJD1mQTY+fHA3kwFfh+k2UR
XWcYxRTFIEcK3guVzKBYk0FyBT9A6xBu88En7yzgBUC9fqwwmzN/Q4msIXVq2Ep4
/7p28YQnLEa+PJmQJlLN5bwEBbrsyMAvyvmVU4JbUznIc+o2mCx2Lny9Bv64NAYS
aesIxwp9Qn4enkYtvqdSfyTonEZRyA+O5gmcjPgpZfIuHYiVPgP2Kibr36T9TU5L
CjnKblyRvHyM0a0jo2hfh3D7HNPBzp11aWuB5/wJ3pxqL9yjzdmSKfTW8SWoKgYL
yObnt3e/d4Zm+yZ2+J/THP4AtTZfo4M365Swo/rypDjuecwvOXyTiGA+nbZUXF/k
j8ptkAvOQQX3GZ1btzWE4Wh9+Q0eO6wO9IopNwvwnffC9k7OZ0AebYfynzsBwv/V
LTtNKC+HGrcpvw1gxpF4rnkmjjPWHtn413GwKLNaGMBVmTZ05gofIuR2sQijBRfy
6JF2sFkMro16WxcGf0rw
=estl
-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


Re: Can't take value of a macro aka macro noob needs help

2011-10-30 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

your magic eye is right. using a backquote fixed it

Am 30.10.2011 15:37, schrieb David Powell:
 
 
 On Sun, Oct 30, 2011 at 2:22 PM, Dennis Haupt
 d.haup...@googlemail.com mailto:d.haup...@googlemail.com
 wrote:
 
 -BEGIN PGP SIGNED MESSAGE- Hash: SHA1
 
 i played around a bit
 
 (defmacro times [times  exprs] '(let [countdown# ~times] (loop
 [remaining# countdown#] (when ( 0 remaining#) ~@exprs (recur (dec
 remaining#))
 
 
 It looks like you have an apostrophe in '(let - it should be a
 backquote.
 
 Also the error message is confusing because you have named the
 parameter times and the macro times with the same name.
 
 -- Dave
 
 -- 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/

iQIcBAEBAgAGBQJOrWkcAAoJENRtux+h35aGhXsQAKlTzH85uqEBSGQsGHwBRYZK
nn7xxj/eWbP/nmIhPiHZhBXAkgPfItQZl3SHwjwiKgs5xS8MJVFXZKhRW/2AX6RQ
jIxe2ORK+CmfZamDzeaRnf1dql32aV1qOxb2hXC/VvaAxP1bLOw1X4iykXB8kqFE
AUEMMGnilpWiihYqGGFYxlE3TzvVYUK2SCmah9CESYjW7PyR9QyiAZYvDxfGqC/G
As+JbDloapSt2FiTsNzjXZ14/qlGRhlfP3p3bdZmLlpDpzFrbPnka95QCXS7yG3P
hIvRVTUGkOec3jRWWEAXWnzEURu1LF26KB1QMuJHV+EB7tS+mqGXuwaW5mSiyi/b
U2zKdV5QePvkjk0BkXSDtKnZXP2Mydn/G7PNAwLMdMJVj+yVqV/UlbcU/68lBVRs
g/SDcaSaGzFao+V5iwXLVj4NuTTW4iAvy50nIORtc+A8ikoNhk2+X6+SVkgTo15L
/MNzDF0goC9KpKEt1hJtmJblnyaKqGmXMK45i4QBBiCoHpgYTHdDITfIFqQHBKew
YzBiNkkcS2WkEkkDeQcnsrdMiEw23LjYTz/G4p2j/+VLuKsfDp9Qegat2iVKWAup
EN2Q+302NviZSAGw12en/09k/5PNT5QeBCexHlCI6xkeu5cxJMOQwkgQDzrrZgAP
ZabbzWcl931nYi+XvKxP
=JGAi
-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


anyone interested in a small game?

2011-10-30 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

hi community,

i decided to create a (small) game in clojure to get a bit of
non-theoretical experience. i'm pretty much a clojure noob (only did a
few experiments) but have done a few real things in scala - which is
totally awesome btw - so i do have some functional programming experience.

if there's someone here who would like to join, just do so by
answering yes or something like that.

i was thinking about a game like asteroids, tower defense or that old
game with lots of aliens on the top and two players at the bottom,
shooting upwards.



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

iQIcBAEBAgAGBQJOrZhRAAoJENRtux+h35aGzE4P/2llb/0Pfy/qJSjK0pEM/plD
ySU/CYupObaI3aZN+1aK8LwCQmiznyk6AUa8UcdO9fYcvEXDTBvHbWJUpimG0gUC
pMUuL/wfTqB232gtuNbYMc6zYRoN3ddq4yZIq0QFnbqXI8PaxjQJBaS7J+5DZEGG
JXaaA9RpTL6mnyTxxlw29BwHgmsv+xxbu09yAg8VHABD2TcuRUuz81OKmHTUxxhm
1ZtlP9dw+jVzryNUHfE3lygn+stfIJxC3ui3cf4Rfham+CbhjpseClkXWA4nNYYF
tqsQHxxe76CewXbQBpnKhqPvB9REo+qGdADi6camML5k+i6FYen4QXIvh5bF8PmO
jkOFQZLN2t05pPEmq+lamMmpb3LA2VLVv4zC/m9mEgrJ/rB34Ewv1upU76Qme+OB
r/++jgFeb0OcjdFs4kvJpF7wKFKHJv0nMfyzKnzrx4D0HckrpQdsBGsXjhDqsvZQ
6QwamOZhk9yugPlqgEy3eN6VrKxY9JawQ0H6e5P+DD0F7UyDbYtBk/HcEx916Kjj
CBNEIwImHoR/0uA7Dyzrn08LoaTcej7kSA06UOkOiRaw71T9EnQuOjDDabrzmsyk
Go/R+rPMlgFTpdt6w43dnmmXqrOfKJqmFrvYztKBAulVoibY0ZSkwmKd/cftiYNw
WSOA0yQMG5qN1pBmpiCk
=j+7J
-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


A memcached client for clojure wrapping xmemcached

2011-10-29 Thread dennis
Hi,all

I wrote a memcached client for clojure wrapping xmemcached.Xmemcached
is an opensource high performance memcached client for java.

 It's name is clj-xmemcached,and it is on github

https://github.com/killme2008/clj-xmemcached

A basic example:

(ns demo
  (:use [clj-xmemcached.core]))

(def client (xmemcached localhost:12000))
(xset client key value)
(prn (xget client key))
(xcas client key #(str %  update))
(xshutdown client)

More detail please visit the github homepage.


-- 
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


Re: A memcached client for clojure wrapping xmemcached

2011-10-29 Thread dennis zhuang
An example with more detail is on

https://github.com/killme2008/clj-xmemcached/blob/master/example/demo.clj


2011/10/29 dennis killme2...@gmail.com

 Hi,all

 I wrote a memcached client for clojure wrapping xmemcached.Xmemcached
 is an opensource high performance memcached client for java.

  It's name is clj-xmemcached,and it is on github

 https://github.com/killme2008/clj-xmemcached

 A basic example:

 (ns demo
  (:use [clj-xmemcached.core]))

 (def client (xmemcached localhost:12000))
 (xset client key value)
 (prn (xget client key))
 (xcas client key #(str %  update))
 (xshutdown client)

 More detail please visit the github homepage.





-- 
庄晓丹
Email:killme2...@gmail.com
伯岩(花名)  bo...@taobao.com
Site:   http://fnil.net

淘宝(中国)软件有限公司 / 产品技术部 / Java中间件

-- 
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

Re: Can Simple be done with Static Typing?

2011-10-24 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

i have some (10 years) experience with difference statically typed
languages and a bit with dynamic ones. i encountered a few typesafe
solutions that don't introduce a lot of overhead - for example the
types of scala. in addition to interfaces and classes, scala has
types. a type can be an arbitrary set of field and method definitions,
for example:
type foo = {
   def x:String
   val y:Int
}

every instance that has a method x which returns a string and a field
which is an int are compatible to foo. in java, you would say it is a
delayed interface. the code behaves as if someone magically attached
implements foo to any class which would still compile.

so your (not (nil? (:first-name record))) would work in scala if
there was a type like type bar = {
   val firstName:String
}

it's implemented via reflection, but the types are checked at compile
time.



Am 24.10.2011 15:28, schrieb Timothy Baldridge:
 After watching Rich's talk the other day about Making Simple
 Easy, I started thinking about how to incorporate parts of this
 talk into the software we're writing at work. During this thought
 process, I have begun to wonder, are simple and statically typed
 languages mutually exclusive?
 
 Let me explain by a simple example. In the following text, I will
 be using C# as my example static language, and Clojure as my
 example dynamic language.
 
 For instance, let's say we have two structures, Contact and Staff.
 The two are completely unrelated, except for the fact that they
 both have a first name, and they both are required fields:
 
 Clojure:
 
 {:first-name Billy :age 42 :record-type Contact} {:first-name
 Joe :position manager  :record-type Staff}
 
 Now in Clojure, writing a validation check for this is as simple
 as:
 
 (not (nil? (:first-name record)))
 
 But how would we do this in C#?
 
 new Person() {firstName=Billy, age=42 }; new Contact() {firstName
 Joe, Position=manager};
 
 Person and Contact are unrelated, so I'm left with duplicating my 
 validation routines (once for each object), or going and making
 both implement IFirstName. This gets even more fun when you start
 taking into account generics: In C# a ListIFirstName cannot be
 casted to a ListPerson because they are considered two completely
 different objects.
 
 In the Clojure source code, Rich gets around most of the above
 issues by simply referring to everything as a object and then
 casting to get the type at runtime. This works fine for code that
 will be run in a dynamic language anyways, but makes for some ugly
 code when you're actually writing the static language parts:
 
 if (lst[0] is IFirstName) runFirstNameChecks(lst[0]); if (lst[0] is
 Person) runPersonChecks(lst[0]);
 
 However, this then requires tons of type checks and casting
 throughout the entire system.
 
 So yes, I understand that this is all a bit off-topic for a
 Clojure mailing list, but I thought it was applicable to Rich's
 talk. Are we getting half way to simple, simply by using Clojure in
 the first place? Is it possible to write simple code in a language
 that shuns the use of simple containers (List, Dictionary, etc.) as
 the primary transport system for data?
 
 If anyone has some thoughts, they are more than welcome to ponder
 them out-loud with me on this thread
 
 Timothy
 


- -- 

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

iQIcBAEBAgAGBQJOpZetAAoJENRtux+h35aGhTsP+wUYHLD0i8t4DI7P/d2A13Ca
29hIhICsxJ2IE3svctaobozaT1byzzpYq6NFfqcfdwfOJCAJBCxmrHTiTCQ09EPM
jSZpxiXQSXHtYDpn2AiYA5c5Ut+TXjbWeahKjyRGrUVKjORtPHvaWGccj0b5vzYT
m7QpMy7R0tzEj/w2FCIkWkjqvJeCQ3cYNC78GZ2gIHC9DQwAjeD2uKSX3RfwaD3S
apEJELCYeDS08NIS26uB0ZHbo228rLlr02WaXh/+rx/MlMlEE/MEIq0aqJV59J7J
A6EFqoC43LxpftJRfAJ3MHRoliC0mnGN9SoWKeRiE0i8p1g8pv1e74DpLzI/I/Pq
GeR9TL688wyhnehl8VZW9AEKQVfKOujPIkKdpr4eF98eKdxHdu4xwkKi/ZgL6zCf
h7/eO6QRrKsOLfztMNQsaYqpCP/pFGA2J3p4Q/oVkB2Uqa6xa0auNcY5mBSPNuZp
zKcOg6/gi39eOZxFslVOvnY6ZOcILjRJYoA1VcO834NMd0A+D6lP0UM0ReBb28kg
MLjhDstZC1xVShp9PVJAdMlMeNjRDOPcASQG6uCisTSGfQ7qVXBNYd/SqXyRUODn
YFTSYtncEu+Pq0nRIjl1ItBmP/9saEqqJwiOpW01IAT+mFVv10tqKCxWFJKwNcLQ
iolsrCZa8Yn9Tvt2hFEL
=UbSd
-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


clojure newbie collection question

2011-10-14 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

if i got it right, filter/remove and map (basically all batch
transform functions) return lazy sequences. to convert them to real
collections again, i do (vec lazyseq) in case i want the result to be
stored in a vector.

correct?

what happens if i traverse the lazy sequence more than once? is the
result cached like in a scala stream, or is a lazy seq in clojure
similar to a view in scala that is calculated each time it's traversed?




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

iQIcBAEBAgAGBQJOmHZiAAoJENRtux+h35aGHYIQAKeYGf6BEsBVvlTbxF0NEiM2
O9u8jPnUwpRcqsoslROX8YCKpTjppnG/YpaGI98OkZXPLXK6f3JDo60gV6oF143L
mntpi1RrQ3DDPFfFzsSGpK1k/eoqaR+E6dOeWOeC/FkGjotjaDN4KlJp9PsdaAmZ
2atZX2Nr8Ock+gRnteupJEbWPJ5kbPm0W/cYojnCGKgPcxTZ67BFEnpTtWfYzPGC
v5vn8+OP/dw5kwAgnvQoSl4AVB7BkGFL4dDeKeayR6MstLKlfl8mJeecliZlc4iy
rbMWIu5rHJGYyFDnejzbubfwSkYUrCtfMjvD4Zz69ArTLOrWtKKe+WDFFawi0QeM
gYleGeFPhX9adHF/uyojDljy+LhnX65+2Q5fnUXTa5+QX0F3oxrCs9C0lPJwmYpy
HplJrh7YoeHRXSh/vlBm5Y8FMaIwW2mCn7SmdldHZz0TrURwQaD8hUwgNl6fMPgO
YOe2lopReZofT7jdR40fhtGakv/+RFwhgDZY66zp13b5ab79uhMrt0jMG3pHHwgs
2bBeZol2V+RsROXi2aVOBPrRQWpVDWxQn4Ky/0PV5QjapqTNe/2ZDxtCM7O4acqf
9f7XoY1tWYhWNCCkHtl9VvkqQJtgeJdkODd4+ksu1hhg70JfE++q4Drml31wOpNo
3vCvGa1fsATKhsbzc9zi
=sU9o
-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


Re: Shameless self promotion - JavaOne

2011-10-04 Thread Dennis
Here is a link to my presentation.

http://dl.dropbox.com/u/5831287/JavaOne%202011%20-%20Monitoring%20a%20Large-Scale%20Infrastructure%20with%20Clojure%20FINAL.pptx

Sorry about the file format :)

Let me know if the link doesn't work.

-- Dennis

On Tue, Oct 4, 2011 at 10:17 AM, C. Arel java10c...@gmail.com wrote:
 Hi Dennis and Chas,
 I'd also like the slides if possible. Maybe if you could post them
 here in the group more people can get them.

 Thanks,
 Can

 On 27 Sep, 17:50, Dennis shr3ks...@gmail.com wrote:
 Hey guys,

 I will be giving a talk at JavaOne (it is Clojure related).  Here is
 the information.

 Title:          Monitoring a Large-Scale Infrastructure with Clojure
 Time             Tuesday, 07:30 PM, Parc 55 - Embarcadero
 Length          45 Minutes
 Abstract:               Monitoring a large infrastructure brings unique 
 challenges
 that require blending development and operations concepts. This
 session discusses how Dell Inc. used Clojure to develop a
 data-flow-based monitoring system that stores, evaluates, and acts on
 hundreds of thousands of metrics.

 It covers
 • Real-world applications of Clojure's parallel programming constructs
 to take advantage of multiple cores available in today's systems
 • Using Clojure's homoiconic nature to create DSLs
 • Taking advantage of Clojure running on the JVM to use the Java ecosystem
 • How DevOps takes advantage of the JVM dynamic languages to develop
 new monitoring tools
 Track           Emerging Languages, Tools, and Techniques
 Optional Track          The Java Frontier

 -- Dennis

 --
 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

-- 
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


Re: Shameless self promotion - JavaOne

2011-10-04 Thread Dennis
Good idea.  I am having problems with slideshare displaying the
presentation.  I probably need to get on another machine to try to
convert it to something more useful, and that will take a couple of
days.  I will post when I do.

-- Dennis

On Wed, Oct 5, 2011 at 12:05 AM, Leonardo Borges
leonardoborges...@gmail.com wrote:
 How about putting it up on slideshare?  Pretty sure they can import pptx ;)
 Cheers,
 Leonardo Borges
 www.leonardoborges.com


 On Wed, Oct 5, 2011 at 3:55 PM, Dennis shr3ks...@gmail.com wrote:

 Here is a link to my presentation.


 http://dl.dropbox.com/u/5831287/JavaOne%202011%20-%20Monitoring%20a%20Large-Scale%20Infrastructure%20with%20Clojure%20FINAL.pptx

 Sorry about the file format :)

 Let me know if the link doesn't work.

 -- Dennis

 On Tue, Oct 4, 2011 at 10:17 AM, C. Arel java10c...@gmail.com wrote:
  Hi Dennis and Chas,
  I'd also like the slides if possible. Maybe if you could post them
  here in the group more people can get them.
 
  Thanks,
  Can
 
  On 27 Sep, 17:50, Dennis shr3ks...@gmail.com wrote:
  Hey guys,
 
  I will be giving a talk at JavaOne (it is Clojure related).  Here is
  the information.
 
  Title:          Monitoring a Large-Scale Infrastructure with Clojure
  Time             Tuesday, 07:30 PM, Parc 55 - Embarcadero
  Length          45 Minutes
  Abstract:               Monitoring a large infrastructure brings unique
  challenges
  that require blending development and operations concepts. This
  session discusses how Dell Inc. used Clojure to develop a
  data-flow-based monitoring system that stores, evaluates, and acts on
  hundreds of thousands of metrics.
 
  It covers
  • Real-world applications of Clojure's parallel programming constructs
  to take advantage of multiple cores available in today's systems
  • Using Clojure's homoiconic nature to create DSLs
  • Taking advantage of Clojure running on the JVM to use the Java
  ecosystem
  • How DevOps takes advantage of the JVM dynamic languages to develop
  new monitoring tools
  Track           Emerging Languages, Tools, and Techniques
  Optional Track          The Java Frontier
 
  -- Dennis
 
  --
  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

 --
 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

 --
 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

-- 
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


Re: Using Clojure to Generate Java Source?

2011-09-30 Thread Dennis Crenshaw
Thanks for the advice and support everyone! I'm not hopeful at being able to
sway him to a parenthetical language through logic (I've tried!)

Additionally, I definitely would not consider throwing out unmaintainable
decompiled Java code on the sly. That, as Nicolas pointed out, would be the
ticket to finding a new place of employment. :)

I'll try and make the case with him and our mutual boss for letting me work
with interop until we get some time to re-develop a pure-Java solution. I
don't expect the pace of development to slow down and perhaps proximity to
elegance will make an impression. I have to respect that it's his project,
but I definitely cringing at re-developing this thing imperatively.

-- 
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

Re: producing Blub code and vv.

2011-09-30 Thread Dennis Crenshaw
Nice article in the wiki link, the logic rings pretty true for me. Clojure
is a truly powerful language and I don't want for any higher-level
facilities with it yet. :)

That said, it would probably mean great strides in the industry if elegant
Clojure code could be translated to comprehensible Java code (or to other
languages.)

I feel companies use different tools all the time as long as it results
in efficient generation of their lingua franca (Java, Python, Ruby, etc.)
They switch languages very rarely because it takes a revolution in
philosophy to unseat a considerable investment in a particular language.

If Clojure could translate itself into other languages the adoption
argument would be reduced to getting someone to let you use anther tool to
auto-generate boilerplate (the same way IDEs might generate Java
getter/setters.) Only this tool would come with lots of parenthesis and a
REPL, among other things. ClojureScript being a prime example of Clojure
'speaking' another language.

This type of feature is probably only useful as a bridge between now and
when everyone in the future talks in reverse polish notation. However, I
think comfortable proximity to Clojure's elegance and efficiency would help
other developers slowly become acclimated to, and even secretly curious
about a new way of thinking.

-- 
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

Using Clojure to Generate Java Source?

2011-09-29 Thread Dennis Crenshaw
I'm in a bit of a bind-- I've written some really nice Clojure code for
dealing with Genomic sequences that works as well or better than the
reference implementation we currently use where I work. However, the the
hierarchy has recently changed and my new boss is requiring me to have all
code in Java (eg. interop is not an option since he wants the source to be
pure Java.) Is there any way to prevent my head exploding from
hand-translating my Clojure code into Java?

I'm sure it's possible to generate Java source since we heard Rich's amusing
anecdote about using Clojure to write reams of Java boilerplate instead of
doing himself. Is there a precedent or even an existing library for
translation from Clojure into Java source though? I'd like to be able to use
the code I've got without a long, painful devolution. More importantly, I
want to be able to continue developing in Clojure and just compile it to
Java source and check that in.

Thanks,
Dennis

-- 
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

Re: Using Clojure to Generate Java Source?

2011-09-29 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

compile to java class, decompile to java source. works in theory,
until someone actually looks at the source ;)

btw, your new boss is ... not the type of boss that would keep me from
looking for a new job.

Am 29.09.2011 20:09, schrieb Dennis Crenshaw:
 I'm in a bit of a bind-- I've written some really nice Clojure code
 for dealing with Genomic sequences that works as well or better
 than the reference implementation we currently use where I work.
 However, the the hierarchy has recently changed and my new boss is
 requiring me to have all code in Java (eg. interop is not an option
 since he wants the source to be pure Java.) Is there any way to
 prevent my head exploding from hand-translating my Clojure code
 into Java?
 
 I'm sure it's possible to generate Java source since we heard
 Rich's amusing anecdote about using Clojure to write reams of Java
 boilerplate instead of doing himself. Is there a precedent or even
 an existing library for translation from Clojure into Java source
 though? I'd like to be able to use the code I've got without a
 long, painful devolution. More importantly, I want to be able to
 continue developing in Clojure and just compile it to Java source
 and check that in.
 
 Thanks, Dennis
 
 -- 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/

iQIcBAEBAgAGBQJOhLd6AAoJENRtux+h35aGCe4QANMbLKUwasgC5Ue5O+Ad5ozt
Pl0zWDbS29iPYP7NtafPltBUxypZrkDWlT/8mbZW5bkCe2R5V/JyzVO34eIZsUCs
AhcC7TlIXTl8UQQJVC+zKwZ/S6URHApEKI097rxJVGqKEDqjXS7tytqKXYM4hrOp
H1Iu8SQyGdDgEOjL8VQHTGiPeovM6lzW1evK/iqvlUlgDmD5B11ectI9tSrITPn9
IAl+7RK7FcM7B5PESY+GKG4zbitEy4M1UKNQUq1XaCwx2qWERQMhvNrujjUCO9jX
m+na6X5u7Cl/xBxxl52n053e/zQjJK4rdLAgm6K1x1b/t7kofrf+3D9BLCYdr9GY
/1mYhOm1THXgNCYfZYMbDzEwKSy3molnCbPr7pryqj9IJjJ5fEPAfXmSZa7ESZSm
MeEPKnDEhfKSV+NvuQ9srZL0XrN/YDJ+IIckAc1hoAGKUmH4bf+kkhWkD2+cgft2
PO3DG+5kaXy0rc3lP1XAntTQQufIfTwOu69DFPVhOTKHRaWCn/SxDlW2/D3CytU5
MFc59ZKON6sz3L04/9ihnMonW1E/VYl2dvEL/v67s+hkDfc/la4fNpyDP0jnOa6b
didf/CLOoXDf96gkLe87R9WPdfdMgjrWvq+oz+T1JmUN7mCuwb0ha13JrnxBqLIJ
bBwNY9PsIP0B9nJWZCgs
=C3mv
-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


Re: Shameless self promotion - JavaOne

2011-09-28 Thread Dennis
I am not sure to what extent there will be recording.  However, I can
send you my slides after the presentation.

-- Dennis

On Wed, Sep 28, 2011 at 12:47 AM, Boris Mühmer
boris.mueh...@googlemail.com wrote:
 Will there be any slides or maybe even a recording of this session?

 I would be very interested in this talk, but I can't go there...


 Regards,
 Boris


 2011/9/27 Dennis shr3ks...@gmail.com:
 Hey guys,

 I will be giving a talk at JavaOne (it is Clojure related).  Here is
 the information.

 Title:          Monitoring a Large-Scale Infrastructure with Clojure
 Time             Tuesday, 07:30 PM, Parc 55 - Embarcadero
 Length          45 Minutes
 Abstract:               Monitoring a large infrastructure brings unique 
 challenges
 that require blending development and operations concepts. This
 session discusses how Dell Inc. used Clojure to develop a
 data-flow-based monitoring system that stores, evaluates, and acts on
 hundreds of thousands of metrics.

 It covers
 • Real-world applications of Clojure's parallel programming constructs
 to take advantage of multiple cores available in today's systems
 • Using Clojure's homoiconic nature to create DSLs
 • Taking advantage of Clojure running on the JVM to use the Java ecosystem
 • How DevOps takes advantage of the JVM dynamic languages to develop
 new monitoring tools
 Track           Emerging Languages, Tools, and Techniques
 Optional Track          The Java Frontier

 -- Dennis

 --
 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

 --
 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

-- 
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


Shameless self promotion - JavaOne

2011-09-27 Thread Dennis
Hey guys,

I will be giving a talk at JavaOne (it is Clojure related).  Here is
the information.

Title:  Monitoring a Large-Scale Infrastructure with Clojure
Time Tuesday, 07:30 PM, Parc 55 - Embarcadero
Length  45 Minutes
Abstract:   Monitoring a large infrastructure brings unique 
challenges
that require blending development and operations concepts. This
session discusses how Dell Inc. used Clojure to develop a
data-flow-based monitoring system that stores, evaluates, and acts on
hundreds of thousands of metrics.

It covers
• Real-world applications of Clojure's parallel programming constructs
to take advantage of multiple cores available in today's systems
• Using Clojure's homoiconic nature to create DSLs
• Taking advantage of Clojure running on the JVM to use the Java ecosystem
• How DevOps takes advantage of the JVM dynamic languages to develop
new monitoring tools
Track   Emerging Languages, Tools, and Techniques
Optional Track  The Java Frontier

-- Dennis

-- 
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


Re: can't see the error

2011-09-27 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am 27.09.2011 06:27, schrieb Baishampayan Ghose:
 i wasn't really trying to achieve anything useful - just messing 
 around and see where i get.
 
 now i'm here: (defrecord point [x y z]) (defn genPoints [n] (let
 [random (new Random) randomInt #(.nextInt random) randomPoint
 #(new point (randomInt) (randomInt) (randomInt))] (repeatedly n
 randomPoint)))
 
 is there a way to avoid writing (randomInt)(randomInt)(randomInt)
 and instead something like (magic (repeatedly 3 randomInt))?
 
 This is how I would write it -
 
 (defrecord Point [x y z])
 
 ;;; Only needed in pre Clojure 1.3.0 ;;; In Clojure 1.3.0, -Point
 will be generated automatically ;; (defn -Point ;;   [x y z] ;;
 (Point. x y z))
 
 (defn gen-points [n] (let [random (java.util.Random.) random-int
 #(.nextInt random) random-point #(apply -Point (repeatedly 3
 random-int))] (repeatedly n random-point)))
 
 Hope this helps.
 
 Regards, BG
 

yes it does :)

- -- 

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

iQIcBAEBAgAGBQJOght3AAoJENRtux+h35aG+AIP/j3ufGpS74wSSDv1RyAJjx2V
S7cdRuF4U00tanW1OAn/PYY93iT0wcXBgKowuo/jD9+C0TV5K7/he33KeSRrJCnb
vLEq8B1Um4JOc1V7MZZBaqtIfJcaQ3s5fcPtPdITX97dX79A3WSItU3/Fc+UYC2i
eF7p99dNLToF2KQhQPZ0Wb37gyIit/XExWiuTx8FIkNzLsL/cPQFMJpcG5Thw9pF
6EKImZOH2A6zOgO68nbynxV4D2vOW7VKkJb7B61XgRILf9bfLqspg/GmEeXaBTrp
gNXSbE7AFAHp6bA08nvydfr9H68z1H53i79mLxlDVXsq3MjGiHVddDa1SaG9SwwV
Vt7K0IndKqFonoI5WUj9CRnxWDoDhy35zwSolJOZhAjSSBHDdZCa9fa0BUU5HXu6
15z3RTG9nOk6OIQJeJiKNGaHtPdplJ0ugHFCDhLpsQZoG8z6QWT6n6BxDwRU9w3i
bEobBms8PqEsTWf1MmwJxLPyA/UC0wVKNiMdqheyydVZ/siGJzXN6fgJYFFUXPhT
KElmSJPeV6Ee56GG2ttDFSSblP+At2Kv3zJZQqUnbEhiu6a3L6ofrybTkaUjASWK
KXcnTYEy/ARi2lc+lD39pgM9YKJOOvgX9f3cGFe8mi4B1nZ5nlzrciyN3eJy8QaL
/MJvl1yQRxdWqQX1xLsQ
=vR6l
-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


Re: can't see the error

2011-09-26 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

i don't have the magic eye to spot the parenthesis-errors yet

Am 25.09.2011 22:15, schrieb Mark Rathwell:
 (let [rand (new java.util.Random) nextInt (fn [a] (.nextInt
 rand))] ((map (print) (iterate ((nextInt dummy) 0)
 
 extra parenthesis in three places, and the first argument to
 iterate is a function, not a long:
 
 (let [rand (new java.util.Random) nextInt (fn [a] (.nextInt
 rand))] (map print (iterate nextInt 0)))
 
 
 On Sun, Sep 25, 2011 at 3:51 PM, Dennis Haupt
 d.haup...@googlemail.com wrote: (let [rand (new java.util.Random)
 nextInt (fn [a] (.nextInt rand))] ((map (print) (iterate ((nextInt
 dummy) 0)
 
 
 the error is: java.lang.ClassCastException: java.lang.Integer
 cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)
 
 why does it want to cast my 0 to a function? and how can i get
 rid of the dummy parameter [a]?
 
 
 -- 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/

iQIcBAEBAgAGBQJOgLayAAoJENRtux+h35aG5UgQAJMV850ntNNio3g2HCcaVj4E
LH4KfnIhC0otFrEQQfHg3ha+mBuo9flt55NnHGMfEBNdxCTkfpm0SDzqt6QTKBRA
aGDDJuTyAbmnSvGnOkk60RRqeVS1QOErRyjzrMugNxguNQ5ZUKmZ5GeTndLHn0w0
g81CRfF0CSLD8j9ng98iJOdn/VwyijeATQo2b/DQhkyKHyFzlyGT3LXrRgWYAI5o
NbCzMC1K/0o9LPyP9TGBvOoRrKQ28WzMsJGWhV0bWNmsMzeZokE99UDSUvYpRM+f
OpyL/4MCkW6f1imGWzLpSBMHZqLSwkXX7U2fNrMGj1zi4knir/D3LF+aw5XLmkms
oS6IO5qnttQ1IHCsdC9nflYfk891CNEwgGS9jG7RPJ75Zls6VzYL6zT8V/RN1xr3
3s2fYVH2elIM1SVXphTRsY5bqw7xNa0Jti8ual9j5+t+HiQ8qyqX6Yxf6KQZ+9Ux
EkfpjjFw2Fh4JpJ9dYK1sOncho9j18TLE6afUuTLPYqPlhV5b0AcpPJ3XEA0ayef
U2Plapgp4Jxk6IMGAoMyD/fyaRkiOKIQw+TucWc4F2icX10LjVbM2eacyKLwvwPo
gmgGHfNyRj4dHOmRv40x9JheRiqJdXtuoWEks9wSY3D6sUS3qWNplCwfpJMWhIhT
Dc/HVQYRIunjZ+cGALHQ
=It6H
-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


Re: can't see the error

2011-09-26 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

i wasn't really trying to achieve anything useful - just messing
around and see where i get.

now i'm here:
(defrecord point [x y z])
(defn genPoints [n]
  (let [random (new Random)
randomInt #(.nextInt random)
randomPoint #(new point (randomInt) (randomInt) (randomInt))]
(repeatedly n randomPoint)))

is there a way to avoid writing (randomInt)(randomInt)(randomInt) and
instead something like (magic (repeatedly 3 randomInt))?

Am 25.09.2011 22:14, schrieb Baishampayan Ghose:
 On Mon, Sep 26, 2011 at 1:21 AM, Dennis Haupt
 d.haup...@googlemail.com wrote:
 (let [rand (new java.util.Random) nextInt (fn [a] (.nextInt
 rand))] ((map (print) (iterate ((nextInt dummy) 0)
 
 
 the error is: java.lang.ClassCastException: java.lang.Integer
 cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)
 
 why does it want to cast my 0 to a function? and how can i get
 rid of the dummy parameter [a]?
 
 You have too many parentheses in your code. The error is coming 
 because of the ``((nextInt dummy) 0)'' line where you are trying
 to call an integer (the result of calling nextInt on dummy) as a 
 function.
 
 I don't know what exactly you are trying to achieve here, but
 assuming that you want n consecutive pseudo-random integers, I
 would write it like this -
 
 (let [rnd (java.util.Random.) next-int #(.nextInt rnd)] (repeatedly
 10 next-int)) ; substitute 10 with desired number
 
 Regards, BG
 


- -- 

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

iQIcBAEBAgAGBQJOgO+8AAoJENRtux+h35aGF2kP/3MGVpxqqkax5O0kmX/Kh9u5
b48b6YrlgPwbSvTra2aqs+4rLF4U8mUUN82XyacB+PFAc6PeE3I8/aJudUvFO0RP
c8qL31NKPSm8RTvhPWzBejh2pyu1cP4qZtmgrSFfSan34n/oadfi0w8c1AjHsQqr
MVMMo2gY/U4J68wG2I7bNdbx3VT1OtmZlY04UBh5D9F6NXJ11+hEZLS89K32F6up
hi0EoruOxgeJnWDMLdTsKCUiSzlI8m6ZSlRVu8aj/xkdfcDXQhNVLp/UEmKhX355
wdkZm7VHHKop1c057vlXO8Fz6eUZ2E1RV3jf2osieg3Exj5s4cHncUES5cxZ14NF
6b0Avqxf69yX5ids2OOTaTqWrniRVqhf2KyDZGmgJfgwDyfLxMeephp/3glfYrbf
L3CIsXmjwebtFkwDm9LJvO8DXsOY+NU2ZgwfGCRqbwNxQU+0TMsGGgIypvD2rnM1
zAQE9kmcKLALLOwFcu6hN/OntpjtOk5e51hA7V/1oAk8H0BWOEKW1aYMggwoySgG
ti9BPg8MqyTBtZmqFUyOPFH3EQr8sEjRXpu2Wf1RxATShfNWwalqeOHbEhV/vJkO
SunWpUn/eqKaTzAq+ZI9VrWteMrmklHDlo7PhEwkp6JVFxUj3psfkQeqdY9fSRjz
Ei2jqCQXBMRO2CGEC/+R
=bKcz
-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


Re: beginner question

2011-09-25 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am 25.09.2011 14:00, schrieb Stuart Halloway:
 the website says:
 
 deftype supports mutable fields, defrecord does not
 
 so deftype seems to be what would be a java bean with simple 
 properties in java
 
 Nope. :-)
 
 Domain information should use defrecord, and should never be
 mutable. This is the closest thing to a Java bean, but is radically
 different in being (1) immutable, (2) persistent, and (3)
 accessible generically as a map. Game state would modeled with
 defrecord.

what's the difference between persistent and immutable?

 
 deftype is for things like custom data structures. In a
 Clojure-in-Clojure implementation, deftype would be used to
 implement maps, vectors, and lists. deftype's mutation ability
 would be used to implement transients.
 
 Stu
 
 


- -- 

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

iQIcBAEBAgAGBQJOfyimAAoJENRtux+h35aGtacQALmFsfHsPuCMt/QZM1gfwMNN
e3C0Q2Dju0GgG/PNGTyV25mWII0JGrvl5UK13VLb2q93bNW4l43SeS4glxE1USBd
Btbo1QwGiAkIffhSrcXLQT+2K4PM4b0fbLwkF41obAEVEf3JDpMjZ9Qjxbrz9D7v
WDH+JBx5rQxvk3ctPqtK59OCkH7fRtMM6bLuwHdFc9YhQt7VjmloaZaAmuXfL3+B
sq//dTOuUy94ZZSsERUWWYeqRIvL5gTVkT1QTbElVHCzixH25fnTX8G3b/04bmX6
ME2P/3iSsrYdHfO35caRwQfIm29JYkljwER1vyX0n4iotouodOyTxo4s4du5PZM1
G+xWrzw65ejn3Y6GaSOFjb02wJUhku2cHyXcjY+Xdb3RXNgtTBQurW5Jx+wCmGV5
Kj3GtharuM16n4weCS0aK5meNFFmu8Djn11+cWePyjQ9qVos1ei3f8s01bN13Qbv
p1qUh+5D4eJb39A4cETrJpINXIhXf2Ngg7tpyQQjzppT/iqtIVdKHMVFOiazHzh2
1aLFCBRGVoErCukB84fCmwZ9JJP8NiRzyw7choMbNeBREKhX9+WFJfwDZyygrezD
kTRa7F2iwz1gEfO3kP8vevdObmtQdQgAMxQ/4IG4xLtmptfL25U/5pgvvi9jOX5T
WYY70N5yr64Evgw6Bt9S
=y3Ge
-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


Re: beginner question

2011-09-25 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

so there is no difference.

Am 25.09.2011 15:28, schrieb Stuart Halloway:
 what's the difference between persistent and immutable?
 
 See http://en.wikipedia.org/wiki/Persistent_data_structure, which
 now has a nice shout out to Clojure.
 
 Stu
 


- -- 

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

iQIcBAEBAgAGBQJOf3QyAAoJENRtux+h35aGsKQP/jHBNqhUCQfSQ7XjCe3vTlF5
zhjcXmyhWbRUF7fEsrmljtpOu630gAnl51cmlBOwpOQXLmGJg386422GzUtRexG3
A4KcrYEahAKBK5R1Tiu3WMqAr/h3t9oYi6APYaU29qJqqO6lnZR/bp1yAR+wnmZT
ausVGzUlE+p5DlfWHAMaAsEVYp1XX282BKecgr/cHsBy9Jwl2NdWQl0Ss/ZYPj7x
JE04/y6T/1jomWdM+dwXZ/oCucWmDjSgg3nHMUy/P9yab0kN2qHprqomBCBQeOpj
zY5KS2/0x6nS9XpNfKF1f7VdqG8RkVdE+iE14a5uzCWzAQfMbeZUQcyOv8H8QQXU
v0VYO1htvWwoJRqoCUan5UhrucM+LDqFEml7n8S4y7kbWWy9CJHD0bq9VjgIBIJY
oo8VrFM7ciO+9mmJ7VfdNmUKPmcclWVFp3PVbNKJVMFXO7s+Myj5y/irWDJ3fBTY
VYiCKNtbU9uaNZRVfyTQhVF5i+607BfH78S6wA1fEXYWWcvNiwEBoTaKi4cHh6wF
nbaVf2xOLahJngEg6m8yBQfcnRm5H6WZ2h53UA+c1AgwiRgOAt+FGiK6J695EZbp
LlslJGUH9QVZXsDVWPthtr2Qk8fJtT7c7UQksfYU+F8lANtyTMcN/kAQ2ngZ2pbq
aLOthkidIm51E9NkBRH5
=SNNL
-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


Re: beginner question

2011-09-25 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

so persistent is immutable + x like car is movable + x. it doesn't
make sense to ask what the difference is.

Am 25.09.2011 18:59, schrieb Phil Hagelberg:
 
 On Sep 25, 2011 6:12 AM, Dennis Haupt d.haup...@googlemail.com 
 mailto:d.haup...@googlemail.com wrote:
 what's the difference between persistent and immutable?
 
 I have written a summary of this distinction on my blog: 
 http://technomancy.us/132
 
 Hope that helps.
 
 -Phil
 
 -- 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/

iQIcBAEBAgAGBQJOf3/bAAoJENRtux+h35aGFrIQAJCTY0ZVAQ1LHda9tIkiV/am
hi/bSleO4qFJceGUWuoDP8nrTIc6kDZrhNv7IIYeV59GzETYsEctfUIIosNEnS94
Oya6DpoOWLFlVwLsSVrIkFNbl5WEnEhoi7myO3zxuO0PksefmzLs57oC5ijw24PP
3CQrGiLpO1dI9s7bk8fBEuBDnC+d0GOZH4YAa3EYMp/1VQoRFLgBy3Occ1DVcqcZ
nTac2Gexru0vA9On1RW6d0xSNEPQk33gAnt5fU72LCTi9bAekEPb66y538LKElS4
0nc4x6rEI9ijOLxvTkariCPEIy3yGZ5NcQxZWI1XR1c6J5sD8rsB3d5HZTzsy2Ez
n4NnRXw/zrIxyqLWwoYaZyfqltJdoIvE2qf9d4zMmuj0JHlW518GF7M3aXigdImt
uuSqQkUJ4tadSb/UKWITqEN+F/UpaohNamnWLCbvgDl4MGJ2kGU46tC91Su4N79e
iPfZ3gcyNMuRuO2i2v31OTw86TOwxGhtAJEEDvL8MRIce038fpt+QVybHUsDiGzS
G9OczcysVZstfPphSzfUpMsUUUNSc5lmyskYBQV6xiqwC8VOE+bY/+ejlNm4nHQC
8Qdfqzq7sI7gXPg5yUUvc3xaT8RdT/X2FqL1B54g17pz44gDJW9LlvNXNwP0jTOm
cBFvQnI1tQZRvEcqbaTO
=C3n7
-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


can't see the error

2011-09-25 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

(let [rand (new java.util.Random) nextInt (fn [a] (.nextInt rand))]
((map (print) (iterate ((nextInt dummy) 0)


the error is:
java.lang.ClassCastException: java.lang.Integer cannot be cast to
clojure.lang.IFn (NO_SOURCE_FILE:0)

why does it want to cast my 0 to a function? and how can i get rid
of the dummy parameter [a]?

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

iQIcBAEBAgAGBQJOf4ZIAAoJENRtux+h35aG19UP/1tWgqcQifwUI5zHdkKWTcY8
iY9vXGEr3IvTC2nB1yXJESJ6T/4OTpGhUT9ctX+6xGxPHFC9OPUdvnp5gGUOjCFQ
Qa9G8Qc6Za1uc0HFzbWYxP9yi8TAPg1WVA3RF046kKuS/m9X8uUMtCulSJH8y6m4
VmREcGlyQNjgCDMSRmMX5Y7vVuU2e6KoV6VjSopBHzX/sXBsMd0AZcnCRokBUKre
7J1PyK3YKBmRLZ6gdvnOTz4kDBoKE7yrbh2gpIsQciqsawZ0wWYlBou7JceSxtN3
Zwzm64YLxW8f6DjaRL7ZUAwTVMBkIru86hgm2bMK5pFX5f8bzBcmx09eIgd1fgLV
c3bHtFYWzVrCRAGA+7iqeedQiFmkX2aK6yIcEma8KvoPXRlU5XhTiTN4B4sfPrpC
qHM0U30WVIV05qs9E8rW2JDmpm1X7RpkZ9P3PEQXgYV1yJaSjPPyxRC1R0wi7f0o
KUEXu+WO0egLyh3d8kfD1GMR/ztRGlS0UbJ3htqso710uD+R4GzFvRcitF99bQtm
cOgz7sLB0hJTS3AblNhRzwt0CRdsPjHfBixrqbxGbXcLvkXFyoZMebuJwMZNcpzY
wFhgEGyVxShXQASNub3dzNS8peU5fgoAGLexHh46e02K8a1YWjK3OOokZ3W9uCpt
ghqI1/wkly1r9F/FroFo
=+5YI
-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


beginner question

2011-09-24 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

in java, i would start coding a game with a loop like this:
while (true) {
logic();
render();
}

i would store the current state of the world in an object containing
the complete data of the whole game and update its values in each
iteration.

how would i do this in clojure?

the outer loop could look like
(def next [oldstate] ()) - input = current game, return value =
next iteration

(loop [world initalState] (recur (next world))) // - the loop

but how would be world look like? the best (most trivial) thing that
i could think of is for it to be a map which is passed along several
transform functions, for example

(def playerHealthRegen [world] (...)) - input = world (a map), output
= a new map with a new entry at key playerhealth

each function would then return a slightly modified version of the
world, and at the end, i'll have my completely new state.

is that about right? or is there a completely different way i overlooked?

- -- 

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

iQIcBAEBAgAGBQJOfjE+AAoJENRtux+h35aGo0MQAMipkc8e0YTPxsWsLzaVoQuz
MtXerKHHqqbuyxy+mzlc4xFfFUfs//wQGdk/ExZhby7eNVBc9AGYKarCyG/DVxfM
HwN7RVHIKDtWoHQk71dthSAzkHgbZvFxjO2W3EkI10rTsCYNFx1WV4o/PMt/KYJj
phmtO9LcHmb/ySsLveTmSdJTYjSDb7ENudLbM2z/4SP9AqN21sU1HRNF/Y4gLnq3
tnnGmbpRU8Xs6xv8O8oluRrhjgpGF58okG+JnnW+aqF95OaDMp2dQ2mPKxcWLzmt
zkMj41jC28By05oVPIIOstB50rOzU0VAQvEJRDohz2E2sxbhFfUci7G/75hvBkYz
vUXeQi4TCYM/gQlOOiAqUuutWpYWBbgL7OOHck3VkGn7UEKBguhkMTO/xGJjFxbY
6/pxIy7i7+DbSXfq+tu5sw2XAS96tctD1dWVdFjfpKukckvcDff3/L0ObKwIxTQu
BN9tqoUOs1Tp2OBJhkEJfaBMgUKqX5+IW/mKARVywNFLRWTAYs74OTO86ei/jTPo
kqwu2NGE9p/iHpLAxin8sz6I34kOlHJ2X7Xi4PBC19mmVgErt+A8MIvELuxhKBYw
BxoWZ11bccphKHFUdEDaj43pd1DqFhLqqpDvFWumUIO48pnDRpYcYcRLZ/6raCXv
apIq/CL5V7UHCJ+d/ANo
=Ckx2
-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


Re: beginner question

2011-09-24 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

i assumed my game to be so much fun that no one would ever want to
stop playing it.

Am 24.09.2011 22:26, schrieb Matt Hoyt:
 You need a check in the loop to see if the player wants to end the
 game. Clojure doesn't have a break statement like Java so you
 created a infinite loop that will never end.  To make sure the game
 ends you need to have a base case.  Example of a main game loop in
 clojure:
 
 (loop [game-state initial-state] (if (game-ends? game-state) 
 (close-game game-state) (recur (render (logic game-state)
 
 You should also look into records to store the game's state.
 Records are faster than hash maps and you have polymorphism with
 protocols.

if i remember correctly, deftype = map, defrecord = class?
how does assoc work on records?


 Be
 careful of the lazy functions in clojure like map.  It will only
 execute when you ask a value for it.

render should do that

 
 Matt Hoyt 
 

 
*From:* Dennis Haupt d.haup...@googlemail.com
 *To:* clojure@googlegroups.com *Sent:* Saturday, September 24, 2011
 2:36 PM *Subject:* beginner question
 
 in java, i would start coding a game with a loop like this: while
 (true) { logic(); render(); }
 
 i would store the current state of the world in an object
 containing the complete data of the whole game and update its
 values in each iteration.
 
 how would i do this in clojure?
 
 the outer loop could look like (def next [oldstate] ()) -
 input = current game, return value = next iteration
 
 (loop [world initalState] (recur (next world))) // - the loop
 
 but how would be world look like? the best (most trivial) thing
 that i could think of is for it to be a map which is passed along
 several transform functions, for example
 
 (def playerHealthRegen [world] (...)) - input = world (a map),
 output = a new map with a new entry at key playerhealth
 
 each function would then return a slightly modified version of the 
 world, and at the end, i'll have my completely new state.
 
 is that about right? or is there a completely different way i
 overlooked?
 
 
 -- 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 mailto: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
 mailto:unsubscr...@googlegroups.com For more options, visit this
 group at http://groups.google.com/group/clojure?hl=en
 
 
 -- 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/

iQIcBAEBAgAGBQJOfkN+AAoJENRtux+h35aGWBkQAKnIObEE9/uJV2FdOnOLEZ0P
nDSqdKvGr95+OdX24cTQqYcnsjYogaUSFaDjTEl95x68B2SKcAxKSrl35KMbAfry
pSYmcrRDEjDzjKMQf8RY1h5IMvacJFvpcuCX+VT96RCqBwTtjaLC4xG/iGpwLD5T
n9BAn6D5Js5HosAXg5bsu+0g4Lg04L/skaRsrPtA6YvwEkA+7IMCX2Y1s6zmZwYD
ciNWhVvBFsLiFtrPSmgCRw3tAPBWjx8JrtjvMtq5nrdi3hBQMUtSxOdTwWhbKwdT
V4LwynaTt8fusXVrV9cKlWVHH28o6OED2j8fh+Ndrz6MiG89Pjp0DXIYfHJECS4a
N5Pwvs1ID2l78yhoAlmU6IvaQyEcqqR2NzTxqXrv/HqbUYbfnZeX3HX7d6sCTec9
bJ3fFn0mpW8WFF7VCE08A90bNepISBcTMJ7RsI4fRoke/Vvt0DFU3IjyfHwy/Cil
4n3Slt0UsuCIZi+p+sG6zrI4PXDJ4JZ3QoWP7VQM2IerVPAdqw4srP2MHwrwQ17J
MdZFqqEF9ANke+rqQQDiZUGizgA8UT/VYlwUOHnKGqBoegt2TUhb69htvbaKwAIJ
PZMXbKn7eImS/KUQTNFZNYaKWkJJsE4HJ9Ac2EearQ8R6I6N65BKBITdXp+jVd2s
mgt8Hyn3Lgbdk4mTVH8U
=tnGf
-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


Re: beginner question

2011-09-24 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

mutable? like in not functional?
*reading*

Am 24.09.2011 23:11, schrieb Matt Hoyt:
 Both of them are java objects.  Records has more default
 functionality like implementing equals, hashcode, etc.  You can
 read more about the differences here: http://clojure.org/datatypes
 
 assoc for records sets the value of the property for the record.
 
 Matt Hoyt 
 

 
*From:* Dennis Haupt d.haup...@googlemail.com
 *To:* clojure@googlegroups.com *Sent:* Saturday, September 24, 2011
 3:54 PM *Subject:* Re: beginner question
 
 i assumed my game to be so much fun that no one would ever want to 
 stop playing it.
 
 Am 24.09.2011 22:26, schrieb Matt Hoyt:
 You need a check in the loop to see if the player wants to end
 the game. Clojure doesn't have a break statement like Java so
 you created a infinite loop that will never end.  To make sure
 the game ends you need to have a base case.  Example of a main
 game loop in clojure:
 
 (loop [game-state initial-state] (if (game-ends? game-state) 
 (close-game game-state) (recur (render (logic game-state)
 
 You should also look into records to store the game's state. 
 Records are faster than hash maps and you have polymorphism with 
 protocols.
 
 if i remember correctly, deftype = map, defrecord = class? how does
 assoc work on records?
 
 
 Be
 careful of the lazy functions in clojure like map.  It will only 
 execute when you ask a value for it.
 
 render should do that
 
 
 Matt Hoyt 
 

 
 
 *From:* Dennis Haupt d.haup...@googlemail.com 
 mailto:d.haup...@googlemail.com
 *To:* clojure@googlegroups.com mailto:clojure@googlegroups.com
 *Sent:* Saturday, September 24, 2011
 2:36 PM *Subject:* beginner question
 
 in java, i would start coding a game with a loop like this:
 while (true) { logic(); render(); }
 
 i would store the current state of the world in an object 
 containing the complete data of the whole game and update its 
 values in each iteration.
 
 how would i do this in clojure?
 
 the outer loop could look like (def next [oldstate] ()) - 
 input = current game, return value = next iteration
 
 (loop [world initalState] (recur (next world))) // - the loop
 
 but how would be world look like? the best (most trivial)
 thing that i could think of is for it to be a map which is passed
 along several transform functions, for example
 
 (def playerHealthRegen [world] (...)) - input = world (a map), 
 output = a new map with a new entry at key playerhealth
 
 each function would then return a slightly modified version of
 the world, and at the end, i'll have my completely new state.
 
 is that about right? or is there a completely different way i 
 overlooked?
 
 
 -- 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 mailto:clojure@googlegroups.com
 mailto:clojure@googlegroups.com mailto: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
 mailto:unsubscr...@googlegroups.com 
 mailto:unsubscr...@googlegroups.com
 mailto:unsubscr...@googlegroups.com For more options, visit
 this
 group at http://groups.google.com/group/clojure?hl=en
 
 
 -- 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 mailto: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
 mailto:unsubscr...@googlegroups.com For more options, visit this
 group at http://groups.google.com/group/clojure?hl=en
 
 
 
 -- 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 mailto: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
 mailto:unsubscr...@googlegroups.com For more options, visit this
 group at http://groups.google.com/group/clojure?hl=en
 
 
 -- 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

Re: beginner question

2011-09-24 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

the website says:

deftype supports mutable fields, defrecord does not

so deftype seems to be what would be a java bean with simple
properties in java

Am 24.09.2011 23:11, schrieb Matt Hoyt:
 Both of them are java objects.  Records has more default
 functionality like implementing equals, hashcode, etc.  You can
 read more about the differences here: http://clojure.org/datatypes
 
 assoc for records sets the value of the property for the record.
 
 Matt Hoyt 
 

 
*From:* Dennis Haupt d.haup...@googlemail.com
 *To:* clojure@googlegroups.com *Sent:* Saturday, September 24, 2011
 3:54 PM *Subject:* Re: beginner question
 
 i assumed my game to be so much fun that no one would ever want to 
 stop playing it.
 
 Am 24.09.2011 22:26, schrieb Matt Hoyt:
 You need a check in the loop to see if the player wants to end
 the game. Clojure doesn't have a break statement like Java so
 you created a infinite loop that will never end.  To make sure
 the game ends you need to have a base case.  Example of a main
 game loop in clojure:
 
 (loop [game-state initial-state] (if (game-ends? game-state) 
 (close-game game-state) (recur (render (logic game-state)
 
 You should also look into records to store the game's state. 
 Records are faster than hash maps and you have polymorphism with 
 protocols.
 
 if i remember correctly, deftype = map, defrecord = class? how does
 assoc work on records?
 
 
 Be
 careful of the lazy functions in clojure like map.  It will only 
 execute when you ask a value for it.
 
 render should do that
 
 
 Matt Hoyt 
 

 
 
 *From:* Dennis Haupt d.haup...@googlemail.com 
 mailto:d.haup...@googlemail.com
 *To:* clojure@googlegroups.com mailto:clojure@googlegroups.com
 *Sent:* Saturday, September 24, 2011
 2:36 PM *Subject:* beginner question
 
 in java, i would start coding a game with a loop like this:
 while (true) { logic(); render(); }
 
 i would store the current state of the world in an object 
 containing the complete data of the whole game and update its 
 values in each iteration.
 
 how would i do this in clojure?
 
 the outer loop could look like (def next [oldstate] ()) - 
 input = current game, return value = next iteration
 
 (loop [world initalState] (recur (next world))) // - the loop
 
 but how would be world look like? the best (most trivial)
 thing that i could think of is for it to be a map which is passed
 along several transform functions, for example
 
 (def playerHealthRegen [world] (...)) - input = world (a map), 
 output = a new map with a new entry at key playerhealth
 
 each function would then return a slightly modified version of
 the world, and at the end, i'll have my completely new state.
 
 is that about right? or is there a completely different way i 
 overlooked?
 
 
 -- 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 mailto:clojure@googlegroups.com
 mailto:clojure@googlegroups.com mailto: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
 mailto:unsubscr...@googlegroups.com 
 mailto:unsubscr...@googlegroups.com
 mailto:unsubscr...@googlegroups.com For more options, visit
 this
 group at http://groups.google.com/group/clojure?hl=en
 
 
 -- 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 mailto: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
 mailto:unsubscr...@googlegroups.com For more options, visit this
 group at http://groups.google.com/group/clojure?hl=en
 
 
 
 -- 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 mailto: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
 mailto:unsubscr...@googlegroups.com For more options, visit this
 group at http://groups.google.com/group/clojure?hl=en
 
 
 -- 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

Re: advantage of dynamic typing

2011-09-21 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am 20.09.2011 22:55, schrieb Islon Scherer:
 Scala is a OO language with FP support, clojure is a functional
 language with OO support, they are very different. It's normal for
 someone with a OO background to think that every method receives a
 object of some kind and it's good to know it's type in advance, and
 if you want polymorphism you create a subclass or implement an
 interface but in clojure functions are polymorphic not classes. 
 Let's take the function first as an example, if you give a String
 to first you'll get the first char, if you give a vector or list
 you'll get the first element, if you give a java array you'll get
 the element at index 0.

yes, but you magically need to know
a) for which types does it work? if you give a byte to the function,
will you get an error, or its first bit? or its first char after its
been converted to a string?
b) if i want my data structure to support this, how do i have to do that?

both questions are answered by a signature. the java one would be via
an interface, and scala offers structural types which are much more
elegant in this case:
  def first[A](fromThis: {def first: A}) = fromThis.first

if that hurts, you can extract the type definition:

  type SupportsFirst[A] = {
def first:A
  }

  def first[A](fromThis: SupportsFirst) = fromThis.first

the compiler will tell you if whatever you want to put in there
doesn't have a method first having a matching signature



 In scala each collection class has a overriden first method so you
 can have a static and pre-defined return type, in clojure the first
 function is itself polymorphic so it doesn't make sense to say that
 the return type of first is Object because it depends on the
 parameter. You can code clojure's first function in scala but the
 parameter and return type would be Object, and you would have to
 typecast it anyway.

no, see above. i can tell scala (and even java!) to return whatever is
coming in

 (Maybe with scala's extremely fancy type system you can create a
 generic first function a la clojure but the type signature would
 make my eyes hurt :) With doc, source (the functions) and the repl,
 a static typing system would'n be that useful
 
 -- 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

i have to object. a function signature in scala that takes something
(A) which contains something else (B) and returns such a something
else (B), for example first, would look like this:

def first[A, M[B]](fromThis:M[B]):A

- -- 

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

iQIcBAEBAgAGBQJOeYudAAoJENRtux+h35aGB6MQAJqhJKRwW1ZJ2GVfU8jEqtJe
WMuckgmI2aXB2dn862ebQ5XOmbqy45twVICSql85ARJsVoRCJtUaIdu/nsQYQiXa
2cNCPGFgD1VN2woAd0P4glsBdtsfKTirz/HcLNbHlE34sTMHrn8h96TXuupb9XVM
s1Yg0Gdr/sUsvZmvwn/gi+pLQDuvkU0LW0dx+TJv64gm42nWanKypvGSGSzXpQNm
/4ilBEI3peMj9BIV5zZGJqiJoHaJ/cZuCtZEF19ic3o0RhtqPReOr5ud5+uzIQoN
A6/gmoAJ+GQX58XWCPCJsr7INjv9B4Zp/oAzTJ1Br5fZcMfHDRQ7ZurXXuRlxX8M
CkvbvHegVR8IAl9/EF3YlT//CDvHpgLGCTFgngzmmSUQ3MJEQA3g7S7VpE/zZq7Z
tBowTHNf3jOrYNUzrvhnvSMX3aGKvgKvEK0MRkD6zgueVfTGLPwXiUVscYM8/dhP
x0vvo3g5nSSdo5RxjHVnxJbudWDBznRbDSM3yJcDHouSit4MRPzBVLufegJn7sWF
MBK+z4Wd+YDtqL0ieDpS87VVtaTyUVUEdzcnbd6LaFgwyXPyCNYp9B7g4+CBxLMZ
IiRs+CG3LhGWh64LnkZ6Cy9zhkWvION9gb336GafkaGJgke+y+kz0pMCLLjVoki0
nlvrXMuWvS7hiwzOXW8J
=tVBH
-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


Re: advantage of dynamic typing

2011-09-21 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am 21.09.2011 19:58, schrieb Ken Wesson:
 On Wed, Sep 21, 2011 at 3:00 AM, Dennis Haupt
 d.haup...@googlemail.com wrote:
 yes, but you magically need to know a) for which types does it
 work? if you give a byte to the function, will you get an error,
 or its first bit? or its first char after its been converted to a
 string? b) if i want my data structure to support this, how do i
 have to do that?
 
 I'm curious: in what world is API documentation considered to be
 magical? :)
 


- -- 

good point. in my experience, public apis often are well documented
(no problem with clojure standard lib) while in-team-code is rarely
documented at all
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOejZrAAoJENRtux+h35aGZ8gP/0sKZAOSjMLYZgD0pFy9vs5v
54wUcP9/D+YEreM8hW67P1j0lNcRqFzEjPDvGX+dykdrZKOrfQ1xpFboiARusLSn
XbtoO4vlkwxwwMv9kcB6DyWtTsP7vEc9M9jJkHRNEERynk6DKBrtAX0RHXz4Qfyj
uHHovEG+a68vcbrY1C9GqRck/Qqhdn0JjoKwFXkZGEUaPVf6rLRfav/JY8wl5Mj2
AKYhj/0LTUCknqkMFYkflAdLLVFjYLWX+zAeac18E2/RtRFFT5kedhYzHe3CpPY4
x6BaT5hCS/fZkyYR2kzbar1F18RL4vixmg8HbjGceLLOobW2r5EVyNRxQMv8DIpi
XkjZiW0jqC6XFpoK2KVCaMzJwM46SWNoY6xYglV9/prdQ0Jmf5Isa/FVL+T24Mrq
uaI6AzlKMHk4NzfQNEvJYr22q/H9oT8waEPKDMtWgQsFkSwRFotCfkqu1L5T78MT
BlPek1RIZLTPjxt4kXNwdTC0Q52hiLKNNJakIEakHxSdlwmeT+1i3b+v+luFfdw6
6mGb0H8x0pUJKnU/QHFzPA/hPhg0LMOhdwTdvUm+O/7cbFhAakvhLMdUZlEmj70Y
9DugBMLto6bHyMk4kXUyHzP4ProiFmTwNE5P5UFhtl60svAmkxYuQXFl6JeisxX/
zTIgie+GRZPuGSTtcKPy
=pfvF
-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


Re: advantage of dynamic typing

2011-09-20 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am 20.09.2011 05:43, schrieb Sean Corfield:
 On Mon, Sep 19, 2011 at 4:19 PM, Dennis Haupt
 d.haup...@googlemail.com wrote:
 an advantage i see is very, very concise code since you have no
 type annotations at all. the downside is that exactly this code
 might be unreadable - because you just have no idea what it uses
 and what it does without tests or documentation.
 
 I find Clojure code more readable because it is generic. Instead
 of some algorithm specialized by type, Clojure often deals with
 simpler generic algorithms that are applicable to a broader class
 of data structures which can also mean more reuse.
 
 Writing truly generic code in the presence of a strong type system
 is often harder word and tends to produce much more dense, more
 annotated code that I find harder to understand. Take a look at
 the documentation for the Scala collection library, for example
 (I'm not dissing Scala - I like Scala, but I don't think anyone
 will disagree that the auto-generated documentation based on the
 library type signatures is very hard to read, at least for the
 average developer).

i tend to completely ignore all non-trivial type signatures and treat
them as what constraints are in a database. rules that prevent me
from doing things that are obviously wrong.
for scala's collection framework, that is enough. i can use it
perfectly well, i know exactly what it does - i just don't know *how*
in detail they work.

but the trivial stuff like this parameter must support method x or
always returns an instance of type x really helps.


- -- 

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

iQIcBAEBAgAGBQJOePUTAAoJENRtux+h35aGGHAP/j0gCcyJIBntewvQCTgaS1Xz
lOj4WnrJAfMWKK/Z2r0IBgKBCI8lwqRCYvzqDMa0tVi/Lnfk8tMVMjU2x0KSX1sZ
BRSoWaueQzHmnbqtCr83vfeIhz9XngmeY8b8vJ+8WjYylK2OyUlfq6I2LhR/fy1M
Un8SIiMT3RtUypDdWgHBALMNXnWbw+ToHHLOKX+XpXv4FjP8G8q6g/H2vouIAt0i
tCEPom2aVpGguf2f3V49jcIzU03hwKM2qfnyF4B4rejuS17kGbpBSlaavdSfQus0
sv/s14EpoIOKcIp5SQqRRE96GfmHlopshNuoB4oS3qt57oeSudI20pl/8K/zdI6y
7CajeZUA/Sl56syjTjbdq0bwOcUwWrXJVDJefJ4tgSYJu2hQnTST6NS0Op1+Mm71
nTFG4+SgEMzXoT20NGoE16wKtJn//XLkKHzQ0h/1FvSJ6pTRL/+o8hj/lDA5Y/FD
qLBGaJl6z8jXB8Nltv4nTCS24ZUAn8eDOhv184OvtkTxXXu7MZnu/XPoVueRrbzP
/AWLjqPwko3MdEp8/ApqtKSdZ23rW4cm5Yxo/zytCoGoDSDu7/8m5XiWKUU2Oa2R
MY8EUPcRz+qawE4CaFIevzLb/EfMgJnbtvBZ9LD6VQApFweIMO1/Rc6J1rRavwps
MJWJC58v8gH0AKzs0lv5
=Rlqq
-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


advantage of dynamic typing

2011-09-19 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

hi community,

clojure is dynamically typed, so i thought here i might find some good
reasons for that. what can you do if you sacrifice compile time type
safety?

an advantage i see is very, very concise code since you have no type
annotations at all. the downside is that exactly this code might be
unreadable - because you just have no idea what it uses and what it
does without tests or documentation.

another advantage are macros or macro-like constructs at compile time,
for example:
resultset.columnname
here, columnname could be translated to
resultset.getObject(columnname).
you could even go a step further and use the column names as local
variables.
again, conciseness to the max.

what else is there? is it worth sacrificing type safety? and is there
no way to combine both?


- -- 

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

iQIcBAEBAgAGBQJOd7HzAAoJENRtux+h35aGPfwP/iwwAdhTDfCmTzmMnp6QYnjf
PEz+DDr7RxnCpTI/ptL73lSeFs2ctQGllzWgf6I2tZU+yB06ReGu/piIIZW/Z+sx
3TtIK+w9r3Jzz8lI0AljM5kfo+Zo/1OBgVaGkxon1NPbhZBnH0FpfeU43H7FnuhA
7bOu3HceOf8ju8fNNQmS+LLoueQJBEaRNn/tWkk5a/y1Ipg5hbETe/YL1+VnpAMg
xyIRkfDFwtIlnZ8+0IMpdusI7PBOj+v9VINtSkAUkZptz9wvSFj4JghXU6Mw8dUp
ATZSWGgdXZUrihNQ90K7OlIBG3xFrGiddSO5Gphe+PQFOwxaAf9x3z1opXVYJqt/
7u64JHdqTQkBe4TUSEh5024CdgpLIRvXh54fthl84yjfGeodvibdEwCwg6NSF80o
vl5XzeAuB/xaDkvlAE6aq2peh8+foJAxiiWoc+pKZOxYMm1lwKWTbYnnp0Slr8ym
6CB2dAX+vF/FIV3ctJvJJYcELX/ydTp0p3RoARtHD8QNebRjTlZ2VqLQqRdF1a4b
Nc6tZUAmx1+zYLE+YavBIbgXwssw07MMtJfsyL4tIoX6+q7oQtsdPcVV+4/HvmcX
6d3bzdCHYod6lLcbZvBhm70DUUrxTMdF73VCvNMUwpPq9OvhRd650puMQwC+/zoK
Pob2xj0YER0b1UHNKVFS
=jV+l
-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


Re: small project to learn clojure

2011-09-17 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

i DID care about my robot :)

Am 17.09.2011 04:57, schrieb Alan Malloy:
 Notice something you do often, and try to automate it. Or find an
 open- source project you use, and you wish were better in some way,
 and improve it. Learning a language by means of I need to learn 
 something, what should I do is not as effective, or as fun, as 
 learning it by doing something you care about.
 
 On Sep 16, 2:50 pm, Dennis Haupt d.haup...@googlemail.com wrote: 
 hi community,
 
 i feel compelled to do something more complex in clojure. not too
 big, but bigger than what fits in 100 lines and offers some chances
 to use macros. it should also be fun, maybe something like
 robocode.
 
 
- -- 

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

iQIcBAEBAgAGBQJOdEvzAAoJENRtux+h35aGN8MQAI3lnLB31L1C2brCh4jgWWdo
AOW+nhiF5X47ab3WPnaIrcVOkE89OBQE4/7hXlSqeJD8W6zh4uCIhkFzIKk/p9xN
ISgUBues9qxh8SIhpujCgnhyp44ms8ifHzHlZIiBuR2O2+LBeYKyZIepyZCdjpcf
zZ/4er3lpKB5DTwQ3X+TRAHK4zHC3eEhtSwaLki9AShw2f5abFT5H8Mo/ptSogOt
lkYZHEWNHr2xShBtvJZtXfXTecRisT3Ra3ukkeAldgfRst1LXmy2G44HN1B3Cn+K
9yQJoja4aySqtEKilzADkG2+8AyNK5y2UoGjehca9omGha30KkreyNiyLws/njNn
I6YGBLgzIAgcu+gXTPXqV8j0gE1YBrgTcQvzMTKlOKnA/DG0mJwJTLdfE5q6FNP5
92lAntea0fNBb5RMFpcNa4/c8lGvwgiNAJtAYeX2G1v6MFMavd1nbN/HR3fS3rLQ
wpR6ssPSqjQxQZ5a0MzM/vXJX2qn8/rNqo7RkgLRMv0abOPMCA2FEtxxxsrHetkz
lY/O/B+F6ByKxp5W9xdHE9f2QxfSYf9lXr0eEuHWOeJK10Jj2tYR4WmxB/s/cFNI
KUGTrAeh666TTyzAq93OHLHh7y7lLXY4SwUMyOHO8t1UK0aDMlnZqRWtAHPuN3+r
UF3ujhgj3WbGOeEzPEBg
=ekWR
-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


small project to learn clojure

2011-09-16 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

hi community,

i feel compelled to do something more complex in clojure. not too big,
but bigger than what fits in 100 lines and offers some chances to use
macros.
it should also be fun, maybe something like robocode.

- -- 

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

iQIcBAEBAgAGBQJOc8SiAAoJENRtux+h35aGh1cP/jpv1MaEES/5uTPdbDH3Sx45
hVMMC7zw6q2X1b2yEpfxSJzuDoThS7ptI2vQL2izbr9C0fwuBxuXgIXgSgLAl14S
mVwnpfn5BIcuNf0QS1QfpJhCLQDJnh+EF13DKnqrNJnP9ACLJ89p8a0CB9SURFCE
SgpWoTrAgNKiF1N+P9uP54N7WhwlQ20qkmn+XZDKLJWa4PFlQEpHM32rwYsYpEv8
1eM+X1xR0Z6LEKjbZGyWOShgvN2j4YdosQUWL7FQku2Z7150g13upt6nLNvF9tC6
IO+xlnJ4T68Joq8o3jOBhw+hMszQ0Ax54UfW2Q1QJjiB/E5Ex7NPhCCPdDKcQSPU
YWEPHhf/ft9mXWxlEXRhLw1C0R4FwZ6OtNdMLx7X7jk/e/DCjFIxyXinyObm6BVZ
sCaX4EzwA16rBeAc3D3LxMigvfm0zxEx1sp1skSyL2HQ7rNb++nR7hJjmd96yT20
MxxbIc0eTj4IZEKz+8W5U+FV7rYa11SREiDq0BBmxi1i3tJarNAAJ9I48OhOFn3y
QSAT4/oblh8xa4+FgFLVnWz9rXNJMhBcgVcA1fxJLvysxG4C3MMOhVBRtR4kBt4x
OcBDNn+yny4FYknxDQMo9l5VJyBuD6AlHIaKK/eBkikaX06Fwkg6/MgzwMtkJ7yR
NT21x0zDCYiXdTa3SNv8
=Gqz8
-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


Re: Clojure vs Scala - anecdote

2011-09-07 Thread Dennis Haupt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

so the scala actors add much more overhead than the clojure equivalent?

Am 07.09.2011 07:32, schrieb Sean Corfield:
 I just wanted to share this experience from World Singles...
 
 Back in November 2009, we started developing with Scala. We needed
 a long-running process that published large volumes of changes from
 our member database as XML packets published to a custom search
 engine. The mapping from half a dozen tables in the database to a
 flat XML schema was pretty complex and the company had tried a
 number of solutions with mixed success in the past. I introduced
 Scala based on the promises of performance, concurrency and type
 safety - and conciseness (especially with XML being a native data
 type in Scala).
 
 We've been running the Scala publishing daemons in production for
 most of two years. Generally they work pretty well but, under
 stress, they tend to hit Out of Memory exceptions and, after a lot
 of poking around, we became fairly convinced it was due (at least
 in part) to the default actor implementation in Scala. Scala is
 going to fold in Akka soon and we had been considering migrating to
 Akka anyone...
 
 But having introduced Clojure this year (after experimenting with
 it since about May last year), we figured we'd have a short spike
 to create a Clojure version of the Scala code to see how it worked
 out.
 
 It took about 15 hours to recreate the publishing daemon in
 Clojure and get it to pass all our tests. Today we ran a soak
 test publishing nearly 300,000 profiles in one run. The Scala code
 would fail with OoM exceptions if we hit it with 50,000 profiles in
 one run (sometimes less). The Clojure code sailed thru and is still
 happily running - so we'll be replacing the Scala code during our
 next production build.
 
 The other aspect that's interesting is that the Scala code totaled 
 about 1,000 lines (about 31k characters of code). The Clojure 
 replacement is just under 260 lines (around 11.5k characters of
 code). Neither code base has much in the way of comments (*ahem* -
 I'm not proud of that, just pointing out that there's no noise
 offsetting the code comparison). That doesn't include unit tests
 either, it's just the raw production code. The form of the Clojure
 code mostly follows the form of the Scala code, most of the same
 functions - it was very functional Scala - with some refactoring to
 helper functions to make it more modular and more maintainable.
 
 The net result is (obviously) that we'll be taking the Clojure 
 publishing daemon to production and we'll be dropping Scala 
 completely.
 
 Kudos to Rich Hickey and the Clojure/core team for creating a
 great general purpose language that can solve big problems - thank
 you!


- -- 

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

iQIcBAEBAgAGBQJOZ6cgAAoJENRtux+h35aGsxoQAKAkmQb/8cxVsHSw1bH6mZjW
Hoea0zi90eO2ds9Wk1wrFjtc0wfPPHdrp0FpZ3w1090BkwyKcRBj/iDM45sP4IY5
grc2I6vaRhfgIIVuaxgUt9HzTCbyjCOxk9xJHpCyY7sIfEIcFwNuzQWVHxgdqG/l
CY/9mDe1Wex3rt2QxCSsUX/+yB5uXaxmAoX5m0jyEAmZzw/46+cVzZ8xMi9Gw1o/
mjI/mvpwTmdGcPkh7DamIEU8QjYbNBosgPWpNktJzmhtUaFdXhEMxdyDhldzUcJZ
J8tZZkTWZoQqPfVdMPgfe1blDtV+nse8X2HDqed+Df42TU1YY+1VJ7e8jfr3vV62
cI+6SAqYTT91UC57GkmYKVOm01vNMpp98+fxaxBHUQi64tv/hIkWG4iHRgBCvncR
hdIKfmzVwcPGrOZu6QT0RrVQzeEbz83+3l4CZQ7KOdL8k5vjd5b1T/LsPrQM1rod
jDAn481tmpZKtSLe8+QbSakxfIFT9oTKUXbtDEEkN2CbJOkE4/EQwuCc/gnlo9Mr
YPlPfx96JLxBfVq6JZ92VSdrpnEBS65HjKhWF587XjGjTqzYbbCNJIekwRdqga8e
zkonzIj+IgnuZznV/fbKZ2yCEnO85TXoj0ZWUDnw0Ffvu2vUFvSF0ykR2BHxZBFD
a1yhe/wr8AGyvIff6Hj8
=N1zz
-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


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 x y) player))

(defn winner [field]
  (letfn [(rowOwnedBy [row player]
((let [beginIndex (indexOf 0 row)
   currow (subvec field beginIndex (+ 3 beginIndex))]
   (= [player] (distinct currow)))
  ))
  (colOwnedBy [col player]
((let [beginIndex (indexOf col 0)
   curcol (take-nth 3 (drop beginIndex field))]
   (= [player] (distinct curcol)))
  ))
  (winPred [player]
((loop [cnt 0]
   (if (= cnt 3) false (or (rowOwnedBy cnt player)
(colOwnedBy cnt player) (recur (inc cnt)))]
((let [winnerIfExists (filter winPred [p1 p2])]
   (if (empty? winnerIfExists) open (first winnerIfExists))


(let [moves [[0 0 p1] [1 0 p1] [2 0 p1]]]
  (defn fold [field nextmove]
(withmove (nth nextmove 0) (nth nextmove 1) (nth nextmove 2) field))
  (let [endstate (reduce fold emptyfield moves)]
(println (winner endstate


i'm getting an exception:
Caused by: java.lang.RuntimeException: java.lang.ClassCastException:
java.lang.Boolean cannot be cast to clojure.lang.IFn

in this line:
(= [player] (distinct currow)))

why does clojure want to cast the result to IFn?


Am 04.09.2011 19:57, schrieb 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 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/

iQIcBAEBAgAGBQJOZhuaAAoJENRtux+h35aGaF0P/1xnMYA/gUuvGsBnmM5VmGBQ
ncU9+3E8h4EKClatl0rdo+B4BLObYsyg7Xb3IPVdGCf5lofQVOneX2Uk41tVvM/Q
E98uxotCMUjVcaOuEtLUMNBOQCy0q31erOzdKlaaecQ2KTY+GvBRRxpAbo33uqmP
DaGmSiyzTGkVp9PhKcMzEjneSOagEA6oG0cOOInarfQS8Q7gQXP6Wir63kVcps72
yhtNuJmhyTOQQ7H2c+j/+mawk12YHPmD4TmLLg2/cG3ZEeaGdWS2DeWL8FVKuZ4/
grYnP1PldaOCTsrcDDCEwkM/eNxCSVqopz3LIS7oyhr8eEp9j1/Gkko56YZZYWhL
ITHE083+QZ7gi/F+kQmz3Yrd8ZCeoWW7mL18d8qMppRZYlrtywwhKnFARU24VYvB
hh+9Twtv22oqBnQmP3Xf2kisaFGHaf8ke1yz1upvB2L996xo/wRI7rirxWQUZtOi
XLYZIowcPRf27gpTpSFplqO+92awA4pcvOgpqUuIb3FYBmSuIQI9MatQ3IzaHh9T
tlF6hqFWvgkzR98CBnM2RpgE//qb0sM/DC0/lth5jUoULRN3rmpMUiSIvdwDS8TH
60ipp6IG/m8Ou+rqlEF33oPQU8DKVF26DmS5X7zWB/36VioqmuD/STov3qIabAfx
Pw4JDW8nmQwcDb4gSjPI
=Pw61
-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


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 (indexOf x y) player))

(defn winner [field]
  (letfn [(slashOwnedBy [player] (= [player] (distinct [(nth field 0)
(nth field 4) (nth field 8)])))
  (backslashOwnedBy [player] (= [player] (distinct [(nth field
2) (nth field 4) (nth field 6)])))
  (rowOwnedBy [row player]
(let [beginIndex (indexOf 0 row)
  currow (subvec field beginIndex (+ 3 beginIndex))]
  (= [player] (distinct currow
  (colOwnedBy [col player]
(let [beginIndex (indexOf col 0)
  curcol (take-nth 3 (drop beginIndex field))]
  (= [player] (distinct curcol
  (winPred [player]
(loop [cnt 0]
  (if (= cnt 3)
(or (slashOwnedBy player) (backslashOwnedBy player))
(or (rowOwnedBy cnt player) (colOwnedBy cnt player)
(recur (inc cnt))]
(let [winnerIfExists (filter winPred [p1 p2])]
  (if (empty? winnerIfExists) open (first winnerIfExists)


(let [moves [[2 0 p1] [1 1 p1] [0 2 p1]]]
  (defn fold [field nextmove]
(withmove (nth nextmove 0) (nth nextmove 1) (nth nextmove 2) field))
  (let [endstate (reduce fold emptyfield moves)]
(println (winner endstate

a few questions:
is there a better way than
(= player (distinct currow))
?

i'd like to write something like:
(every? (= parameter player) currow

do i have to define the function via letfn before, or is there a way
to do it nested in the code?

and more importantly: is there an ide that can point out syntax
errors? intellij idea can detect some parentheses/braces problems, but
i managed to trick it by adding too many ( and ). i got weird
exceptions and had to check everything manually.

Am 04.09.2011 19:57, schrieb 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 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/

iQIcBAEBAgAGBQJOZiGMAAoJENRtux+h35aGuSwP+gPkuR9tAyHUKUhqCrkFgtiJ
cuuD47EHMyws/IMwqra1RTBaCAaZbJLx9m4sFn9/KLhbGni7fzTt+zAJy1yxyW21
RaqZJC43VgG6xmDQYVt54aY9zzHz3MkI3eXZBY6Wsd0yquu2NZjnleEvoUNzwsnI
nLi0nsyLkLMX6b/QdDj48XaatfeG48i5M+H9MlF7EpesoIntUEHhXRVhK1BnOeCk
ctd4bo0brdszBes7UhZl9abisaiW1vf+rWAAD8HPqcFg4tWUS//SRRmFyEUJtusc
GXwiPI5Meu0fKHKJv5EhQl87BD3lG+vLUn1XspYYmrZKn5G0ZxL7v/L5ol1g7Zs4
doSVsWCkR3zMwyaQgrvj/IuvIMxhWhgXGYwdEBHstPJephlwCRC5sOQCLvjwJB6H
LEV0nx3m2GiWGH+jOqJ2M+j/OwsYNfPxEPRICLpUjm3lR+Whb1l+OL0fMwREgYkS
ySeto5Q2pI+pkwZc1PsM2YMUEBjBToZroIlMZw6N6IUuQPFNJBcHPakRNDUs93Du
nmg8kCGy+thBedbky7KxDW1bmBNFYxEWR2iASXkkIjhUdyrn3hVOxz1D1a6rM3Cb
S2CdXZG5HeiCsqghyQ/m36bqlLf8CTsFz60lb4Q0Wncpn/EDTSyYq76RRPfGoMBu
Nec7CzUkF8sat1lrZKxy
=v1mG
-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


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 
 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 a
 function.
 
 Consider:
 
 user= ((let [x :dont-care] +) 3 4) 7
 
 Hope, this helps.
 
 Stefan
 
 -- 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/

iQIcBAEBAgAGBQJOZiHUAAoJENRtux+h35aGYNEQALHei3B68cM+QR/U4pRC2FkK
cKmHplrziwWcnXysac9cSC9F4mmcDw+JnnYyB4YI4pCb9El8i8E6a53J5GvilOFX
xG8HF6aUxaifticyQS7kpgG47VgeoaT5VKWcpZLFqZM6axSc8MIJ2ArRNCCMZMw3
bLcTEgk0JGWqjeub2b3/pUhFWI23EaCAv4BszKCnGYqhuG847+Ks3Vd0XFO1gKAo
fwEC0QipX2+0T3rrZuF3AjKQpmEN2+iEpE7sTxrgjICXbnEzGAfK395HWc0Kn8KC
+IXI3K2fMkJRB3M1rqRfRf+luxbw48oPgQa/uos/iK4dPcwkODhNCQwq9PFKkNp1
W9j+rLRRm5+n3p/HfIV4GTB3skKY0ij/X00NtsrCE7OM+bs03zAj6qE5ike/bwxv
XEuUSaqR1vR3LgZ5ii6OW1tev1N86cw7Mi7yQBtAFilXEZ/En5dSdEwRTVjDRSoD
nL59wjTNUZUcVTpQ5I4RUTEm8LX+/5d2bU/LHYVjqV49fxY0eDF6f5eMvBXwANo5
I+l/4uf37K3TD+hXGZkh0DcPdxeyltTRoetbtx+OQg64wFxCzz6nxnOytiDInmyD
+k763My95U4Ex9gIxV6r0NSoJb8hcfQEKdru1Liktghc/wMtiBWfuhgRfOO0rZU/
+oP03MYnZzFZD4Hgakz0
=+Tuc
-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


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 annotations, but in
scala it works really well (although it stops at method declarations,
there you have to add type annotations) and such an error (returning
the wrong type in a situation where it's clear what is expected) would
have been highlighted at coding time (even before compilation)

the ideal situation would be something like

(def x [foo] (+ 5 foo))

here, the ide could look into + and check which types could be put
into + without making it crash ;). that information must provided
somehow (hard coded into ide, provided as parsable documentation,
whatever) at all basic functions. this would enable the ide to
recursively traverse the call tree and figure out what can be applied
to which function.

in my example, it would be
x is called with a parameter foo.
foo is given to + as the second parameter of a 2 parameter list.
let's look into +. oh i see, it has to be a java.lang.Number. is it?
yes - k. no - highlight (x param) as an error.






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

iQIcBAEBAgAGBQJOZi28AAoJENRtux+h35aGtQMQAKAemGLyIRP+6h9KaL3ix3U+
qOgupgqNGNtkDZ2ibYlYRfunJKRm8KLwVnh/0jiTBukY8ppOJTgTuUde6abcl10G
pYomKWPNZBxTRAYI4nRtTKk9cEj0yx3CLYislbk4buxgmLCLNSBOLBmWBD7F8Rxz
fR++KLiJJR7JJ/HszrGPr54Vo7AnI1Rfk1+FcX19UJnmIj1qdfLWq8wTSA6oy063
ZinLUBl+3OfATDJlxUMPJdPOjHMDfQ13MlksUVJq4696rhKjvVdMpIpb9REOmg/Y
+ZxKVLBKr+8RruzDcUJwoiVrJOi6f1pXIMzqsKDhaqhDJwr0iHhY98SjkQBAyozI
tLPQmnudMEB6gS7F2/aW2idZ9WD+XiUyoCt2FwplVJqBveBWTAUAXWdpeAl0rmVG
Qjh5hiUgHs4W8X7qmlTzsZPFlwJ+rYZoHzqaw6HcWnGX9H6gv2ExM1+ELJ25dTHh
0AJZl26WLZ7eXZNAeO62FDET64RR3Oib6tVDTzP41IdLzjUx+zwFjfQFOVlEE/Cx
m5azpk8d11zytG2nlcC58Yg8SBz0ZGyTtv4JJ139JqJdVzpYeol7QXZbkrgY5w3/
DQ5+bW7QjqxmD4FbjTcIDcxWcyg+SXda5p4O1ZqxQSWhNa6EzLrWPLufFBfsNyQa
kUjdYxBTJkgtbhl8jxLb
=6RyY
-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


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://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOZi37AAoJENRtux+h35aGzQEP/RlGgWN0hRuCTBjyR7/692DH
oTpAdu06MFU3jT7dPiXy1lHG/ZBZantNaHKALLKfREV+yHCnoQJUuGXRRUn1lDrF
uMmMreujblbeviL9h+S0pJ9q1yTk/MH4+ceHUpM2FzPjSYpsok1OKwGFG7T2Diwb
eg61TAQKV82Uwu9+06LnEwHdySs3JRfKUp4BPjGHYxXEFTQIZGVnFXbjgY5iP4xr
Fi9EBZhdROF8dEk26mxWhxMLoyVx1ZdKe6bnNeAjKsTFnnnGxmot2fgtsJFxM/Rg
D5bSpyEWnw6MlJgpUwDOfASCEbGDCS/oaF5pij7045apJLSVro1Py0/+D5TBiuwI
OVq9mCURWeevHTISlUKHFskwJ6PlQ0rUxuXdoU+IEjdEXOw4+W9DJ4fMKk/HbDku
SteyTeA3xOk4lLIIeq1t1Fhv0FwDFPisa2UcqEV6yMcrC4J9TySEnKl4hynbT+On
g+VXDbTAJucCF4ltFTjPCZyAzZe5A4G6NktBlZ8NvBblERthbsLIX3JZMfoayxSv
Fe5KVsrcbn88VSxVUOrZ9/RHsG+3QYsMRfRTlTCw/8hlVfP3Wg8t3ieieFVIavMg
G1KwUMDDyUaeWt01BZU1c3NqA8NsjBYjukET2tnc35BKetb32I8qeRHu4W9K60Qf
9CHjRZb6IH1J1BLdKCzR
=WeGr
-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


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]
(drop (inc index) seq)))

(defn indexOf [x y] (+ x (* y 3)))

(defn withmove [x,y,player,field]
  (updated field (indexOf x y) player))

(defn winner [field]
  (defn winPred [player]
(defn rowwin [row]
  (let [beginIndex (indexOf 0 row)
currow (subvec beginIndex (+ 3 beginIndex) field)]
(defn ownedByPlayer [value])
every? ownedByPlayer currow))
(defn colwin [col]
  (let [beginIndex (indexOf col 0)
curcol (take-nth 3 (drop beginIndex field))]
(defn ownedByPlayer [value])
every? ownedByPlayer curcol))
(loop [cnt 0]
  (if (= cnt 3) false (or (rowwin cnt) (colwin cnt) (recur (inc
cnt))

  (let [winnerIfExists (filter winPred [p1 p2])]
(if (empty? winnerIfExists) open (first winnerIfExists

(let [moves [[0 0 p1] [1 0 p1] [2 0 p1]]]
  (doall
(for [move moves]
  (let [x (nth move 0)
 y (nth move 1)
 player (nth move 2)]
 (print player )
 (print player)
 (print  makes move at )
 (print x)
 (print /)
 (println y)
 ))
)
  )

two questions:
* 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?

* is there no predefined updated function?



Am 03.09.2011 23:38, schrieb Luc Prefontaine:
 On Sat, 3 Sep 2011 13:43:42 -0700 (PDT) HamsterofDeath
 d.haup...@googlemail.com 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 would like to write
 functions that do not need to know their arguments too intimately. 
 You would like to work on collections, maps, ...
 
 Of course at some point you will need to write functions that will
 look closer to their arguments.
 
 You can pass functions to generic ones and isolate that type 
 knowledge within them. No need to spread this everywhere.
 
 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 problems with simple input and output -
 a*- pathfinding, for example.
 
 but how would i port a complex object graph (let's say 15
 different classes with 3-7 fields each - person, contacts,
 orders, shipping details) to clojure? how would i handle it?
 
 defrecord might help you a bit here. It may feel a bit like
 home. defrecord fields can be referenced as map entries
 (:field-name ...).
 
 You can also define protocols that associated with defrecord and
 may ease your pain by implementing familiar functions to navigate
 in the hierarchy.
 
 Not sure if using a library written by someone else to handle these
 things is the proper thing to do right now. I feel you need to
 break your teeth a bit :) (It took me three months to get used to
 immutability :))
 
 the main problems i see are: * do i have to actually remember the
 complete structure and field names and the exact spelling? using
 statically types languages like java or scala, the ide
 autocomplete features really help here.
 
 If you use obvious names that match the problem domain this should
 be easy to overcome. Protocols could help you here by hiding some
 complex navigation but please refrain implementing getters for
 all individual fields :))
 
 * what about renaming a field or method?
 
 Yep of course you will not have this nice refactoring feature where
 you type in place the new name and get the IDE to fix this
 everywhere for you. But on the other hand you should have at least
 10 times less code compared to java and less side effects to
 debug. It should not be too hard to do this using a standard text
 search. I use Eclipse and the straight file search. I would never
 exchange Clojure for Java and the automated Refactoring
 commands.
 
 If you encapsulate frequently exposed fields in functions you
 should be able to reduce the footprint of the code where these
 things are exposed. Hence the name changes would be easy to
 implement. You would confine these functions in a specific name
 space which decrease the like hood of missing a change.
 
 * if a function needs an instance of the root class of the
 complex graph above as a parameter - how do i know this at all?
 am i lost without good documentation of this function? in java, i
 just know what a method needs because it has a signature.
 
 Use the doc string when defining a fn:
 
 (defn blbl Returns the meaningful blblblbl... string. It expects
 a single parameter, the length of the returned string [length] 
 ...)
 
 You 

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]
(drop (inc index) seq)))

(defn indexOf [x y] (+ x (* y 3)))

(defn withmove [x,y,player,field]
  (updated field (indexOf x y) player))

(defn winner [field]
  (defn winPred [player]
(defn rowwin [row]
  (let [beginIndex (indexOf 0 row)
currow (subvec (force field) beginIndex (+ 3 beginIndex))]
(defn ownedByPlayer [value])
every? ownedByPlayer currow))
(defn colwin [col]
  (let [beginIndex (indexOf col 0)
curcol (take-nth 3 (drop beginIndex field))]
(defn ownedByPlayer [value])
every? ownedByPlayer curcol))
(loop [cnt 0]
  (if (= cnt 3) false (or (rowwin cnt) (colwin cnt) (recur (inc
cnt))

  (let [winnerIfExists (filter winPred [p1 p2])]
(if (empty? winnerIfExists) open (first winnerIfExists

(let [moves [[0 0 p1] [1 0 p1] [2 0 p1]]]
  (defn fold [field nextmove]
(withmove (nth nextmove 0) (nth nextmove 1) (nth nextmove 2) field))
  (let [endstate (reduce fold emptyfield moves)]
(println endstate)
(println (winner endstate)))
)


how to convert a lazy seq into a persistent vector?


Am 03.09.2011 23:38, schrieb Luc Prefontaine:
 On Sat, 3 Sep 2011 13:43:42 -0700 (PDT) HamsterofDeath
 d.haup...@googlemail.com 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 would like to write
 functions that do not need to know their arguments too intimately. 
 You would like to work on collections, maps, ...
 
 Of course at some point you will need to write functions that will
 look closer to their arguments.
 
 You can pass functions to generic ones and isolate that type 
 knowledge within them. No need to spread this everywhere.
 
 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 problems with simple input and output -
 a*- pathfinding, for example.
 
 but how would i port a complex object graph (let's say 15
 different classes with 3-7 fields each - person, contacts,
 orders, shipping details) to clojure? how would i handle it?
 
 defrecord might help you a bit here. It may feel a bit like
 home. defrecord fields can be referenced as map entries
 (:field-name ...).
 
 You can also define protocols that associated with defrecord and
 may ease your pain by implementing familiar functions to navigate
 in the hierarchy.
 
 Not sure if using a library written by someone else to handle these
 things is the proper thing to do right now. I feel you need to
 break your teeth a bit :) (It took me three months to get used to
 immutability :))
 
 the main problems i see are: * do i have to actually remember the
 complete structure and field names and the exact spelling? using
 statically types languages like java or scala, the ide
 autocomplete features really help here.
 
 If you use obvious names that match the problem domain this should
 be easy to overcome. Protocols could help you here by hiding some
 complex navigation but please refrain implementing getters for
 all individual fields :))
 
 * what about renaming a field or method?
 
 Yep of course you will not have this nice refactoring feature where
 you type in place the new name and get the IDE to fix this
 everywhere for you. But on the other hand you should have at least
 10 times less code compared to java and less side effects to
 debug. It should not be too hard to do this using a standard text
 search. I use Eclipse and the straight file search. I would never
 exchange Clojure for Java and the automated Refactoring
 commands.
 
 If you encapsulate frequently exposed fields in functions you
 should be able to reduce the footprint of the code where these
 things are exposed. Hence the name changes would be easy to
 implement. You would confine these functions in a specific name
 space which decrease the like hood of missing a change.
 
 * if a function needs an instance of the root class of the
 complex graph above as a parameter - how do i know this at all?
 am i lost without good documentation of this function? in java, i
 just know what a method needs because it has a signature.
 
 Use the doc string when defining a fn:
 
 (defn blbl Returns the meaningful blblblbl... string. It expects
 a single parameter, the length of the returned string [length] 
 ...)
 
 You can describe the expected inputs and the result,  ... Do the
 same thing with your name space definitions, protocols. ...
 
 It's easy, fits with your programming flow and is non-obtrusive.
 
 


- -- 

-BEGIN 

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
 that allows mutations

no. i am trying to use the function subvec to get what would be a
sublist in java. but subvec doesn't work on sequences, and what i need
to quickly solve the problem would be a function that takes a sequence
and returns a vector.

or i could use a vector the whole time and not use a sequence at all.

but you use functions to hold values that you redefine since mutation
is restricted
 to refs and atoms.
 
 I suggest you look at atoms to hold values if they can mutate
 globally or at recur if you need to implement some recursion and
 rebind new values within a function's body.
 
 Luc P.
 
 On Sun, 04 Sep 2011 18:55:12 +0200 Dennis Haupt
 d.haup...@googlemail.com wrote:
 
 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] (drop (inc index) seq)))
 
 (defn indexOf [x y] (+ x (* y 3)))
 
 (defn withmove [x,y,player,field] (updated field (indexOf x y)
 player))
 
 (defn winner [field] (defn winPred [player] (defn rowwin [row] (let
 [beginIndex (indexOf 0 row) currow (subvec (force field) beginIndex
 (+ 3 beginIndex))] (defn ownedByPlayer [value]) every?
 ownedByPlayer currow)) (defn colwin [col] (let [beginIndex (indexOf
 col 0) curcol (take-nth 3 (drop beginIndex field))] (defn
 ownedByPlayer [value]) every? ownedByPlayer curcol)) (loop [cnt 0] 
 (if (= cnt 3) false (or (rowwin cnt) (colwin cnt) (recur (inc 
 cnt))
 
 (let [winnerIfExists (filter winPred [p1 p2])] (if (empty?
 winnerIfExists) open (first winnerIfExists
 
 (let [moves [[0 0 p1] [1 0 p1] [2 0 p1]]] (defn fold [field
 nextmove] (withmove (nth nextmove 0) (nth nextmove 1) (nth nextmove
 2) field)) (let [endstate (reduce fold emptyfield moves)] (println
 endstate) (println (winner endstate))) )
 
 
 how to convert a lazy seq into a persistent vector?
 
 
 Am 03.09.2011 23:38, schrieb Luc Prefontaine:
 On Sat, 3 Sep 2011 13:43:42 -0700 (PDT) HamsterofDeath 
 d.haup...@googlemail.com 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 would like to
 write functions that do not need to know their arguments too
 intimately. You would like to work on collections, maps, ...
 
 Of course at some point you will need to write functions that
 will look closer to their arguments.
 
 You can pass functions to generic ones and isolate that type
  knowledge within them. No need to spread this everywhere.
 
 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 problems with simple
 input and output - a*- pathfinding, for example.
 
 but how would i port a complex object graph (let's say 15 
 different classes with 3-7 fields each - person, contacts, 
 orders, shipping details) to clojure? how would i handle
 it?
 
 defrecord might help you a bit here. It may feel a bit like 
 home. defrecord fields can be referenced as map entries 
 (:field-name ...).
 
 You can also define protocols that associated with defrecord
 and may ease your pain by implementing familiar functions to
 navigate in the hierarchy.
 
 Not sure if using a library written by someone else to handle
 these things is the proper thing to do right now. I feel you
 need to break your teeth a bit :) (It took me three months to
 get used to immutability :))
 
 the main problems i see are: * do i have to actually
 remember the complete structure and field names and the
 exact spelling? using statically types languages like java
 or scala, the ide autocomplete features really help here.
 
 If you use obvious names that match the problem domain this
 should be easy to overcome. Protocols could help you here by
 hiding some complex navigation but please refrain
 implementing getters for all individual fields :))
 
 * what about renaming a field or method?
 
 Yep of course you will not have this nice refactoring feature
 where you type in place the new name and get the IDE to fix
 this everywhere for you. But on the other hand you should
 have at least 10 times less code compared to java and less
 side effects to debug. It should not be too hard to do this
 using a standard text search. I use Eclipse and the straight
 file search. I would never exchange Clojure for Java and
 the automated Refactoring commands.
 
 If you encapsulate frequently exposed fields in functions
 you should be able to reduce the footprint

[ANN] clojure-control 0.1.0 released.

2011-07-26 Thread dennis

Clojure-control is an open source clojure DSL for system admin and
deployment with many remote machines via ssh.

You can define clusters and tasks to execute repeatly,an example:

(ns samples
  (:use [control.core :only [task cluster scp ssh begin]]))
(cluster :mycluster
   :clients [
   { :host a.domain.com :user alogin}
   { :host b.domain.com :user blogin}
 ])
(task :date Get date
 []
 (ssh date))
(task :deploy scp files to remote machines
 [file1 file2]
(scp (file1 file2) /home/alogin/))
(begin)

More information please visit it on github 
https://github.com/killme2008/clojure-control

-- 
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


{ANN} clojure-control---DSL for system admin and deployment with many remote machines

2011-07-24 Thread dennis
1.What is clojure-control?

The idea came from node-control(https://github.com/tsmith/node-
control).
Define clusters and tasks for system administration or code
deployment, then execute them on one or many remote machines.
Clojure-control depends only on OpenSSH and clojure on the local
control machine.Remote machines simply need a standard sshd daemon.

2.Quick example

Get the current date from the two machines listed in the 'mycluster'
config with a single command:

 (ns samples
 (:use [control.core :only [task cluster scp ssh begin]]))
 ;;define clusters
 (cluster :mycluster
 :clients [
   { :host a.domain.com :user alogin}
   { :host b.domain.com :user blogin}
 ])
 ;;define tasks
 (task :date Get date
  (ssh date))
;;start running
(begin)

If saved in a file named controls.clj,run with

java -cp clojure.jar:clojure-contrib.jar:control-0.1-SNAPSHOT.jar
clojure.main controls.clj mycluster date

Each machine execute date command ,and the output form the remote
machine is printed to the console.Exmaple console output

Performing mycluster
Performing date for a.domain.com
a.domain.com:ssh: date
a.domain.com:stdout: Sun Jul 24 19:14:09 CST 2011
a.domain.com:exit: 0
Performing date for b.domain.com
b.domain.com:ssh: date
b.domain.com:stdout: Sun Jul 24 19:14:09 CST 2011
b.domain.com:exit: 0

Each line of output is labeled with the address of the machine the
command was executed on. The actual command sent and the user used to
send it is displayed. stdout and stderr output of the remote process
is identified as well as the final exit code of the local ssh
command.

3.How to scp files?
Let's define a new task named deploy

  (task :deploy scp files to remote machines
(scp (release1.tar.gz release2.tar.gz) /home/alogin/))

Then it will copy release1.tar.gz and release2.tar.gz to remote
machine's /home/alogin directory.

4.More information please goto project homepage

https://github.com/killme2008/clojure-control

Any suggestion or bug reports welcomed.

-- 
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


Re: {ANN} clojure-control---DSL for system admin and deployment with many remote machines

2011-07-24 Thread dennis
Now it's allow passing command line arguments to task now,the task
macro is changed,it must have an argument vector now:

(task :deploy deploy a file to remote machines
  [file]
  (scp (file) /home/user1))

And run with

 clojure controls.clj deploy release.tar.gz

The release.tar.gz will be used as file argument for scp macro.

clojure-control is still on development,any suggestion welcomed.


On 7月24日, 下午9时41分, dennis killme2...@gmail.com wrote:
 1.What is clojure-control?

 The idea came from node-control(https://github.com/tsmith/node-
 control).
 Define clusters and tasks for system administration or code
 deployment, then execute them on one or many remote machines.
 Clojure-control depends only on OpenSSH and clojure on the local
 control machine.Remote machines simply need a standard sshd daemon.

 2.Quick example

 Get the current date from the two machines listed in the 'mycluster'
 config with a single command:

  (ns samples
  (:use [control.core :only [task cluster scp ssh begin]]))
  ;;define clusters
  (cluster :mycluster
  :clients [
{ :host a.domain.com :user alogin}
{ :host b.domain.com :user blogin}
  ])
  ;;define tasks
  (task :date Get date
   (ssh date))
 ;;start running
 (begin)

 If saved in a file named controls.clj,run with

 java -cp clojure.jar:clojure-contrib.jar:control-0.1-SNAPSHOT.jar
 clojure.main controls.clj mycluster date

 Each machine execute date command ,and the output form the remote
 machine is printed to the console.Exmaple console output

 Performing mycluster
 Performing date for a.domain.com
 a.domain.com:ssh: date
 a.domain.com:stdout: Sun Jul 24 19:14:09 CST 2011
 a.domain.com:exit: 0
 Performing date for b.domain.com
 b.domain.com:ssh: date
 b.domain.com:stdout: Sun Jul 24 19:14:09 CST 2011
 b.domain.com:exit: 0

 Each line of output is labeled with the address of the machine the
 command was executed on. The actual command sent and the user used to
 send it is displayed. stdout and stderr output of the remote process
 is identified as well as the final exit code of the local ssh
 command.

 3.How to scp files?
 Let's define a new task named deploy

   (task :deploy scp files to remote machines
 (scp (release1.tar.gz release2.tar.gz) /home/alogin/))

 Then it will copy release1.tar.gz and release2.tar.gz to remote
 machine's /home/alogin directory.

 4.More information please goto project homepage

 https://github.com/killme2008/clojure-control

 Any suggestion or bug reports welcomed.

-- 
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


Re: clearly, I'm too dense to upgrade slime/swank/clojure-mode... help?

2011-04-01 Thread Dennis Crenshaw
I have a problem with swank with an upgrade recently, clojure1.3-alpha5
works, clojure-1.3alpha6 does not, to my knowledge-- which Clojure version
are you using in your project?

-- 
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

Re: RabbitMQ

2011-03-24 Thread Dennis
We did the same

On Thu, Mar 24, 2011 at 10:30 AM, Mark Rathwell mark.rathw...@gmail.com wrote:

 I just wrapped their java client library:
 http://www.rabbitmq.com/java-client.html

 On Thu, Mar 24, 2011 at 11:15 AM, Max Weber
 weber.maximil...@googlemail.com wrote:

 What is the best Clojure library to work with RabbitMQ?

 Best regards

 Max

 --
 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

 --
 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

-- 
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


Re: Release.Next Version Number

2011-02-24 Thread Dennis Crenshaw
What makes an ecosystem '1.x' vs '2.x' etc. needs to be quantifiable
to make a standard out of it. To quote Peter Drucker, What gets
measured gets managed. Are there any solid examples of languages that
would constitute a good canonical spectrum for ecosystem versions and
why?

It seems like if the ecosystem surrounding a language is another
concern in the semantic versioning equation that can't be sufficiently
be expressed by the existing scheme, there should be a another
digit(s) or a whole other semantic version system for it (e.g. 1.2.0.0
or perhaps 0.1.0_2.0.0 for Clojure 2.0 with a basic, whatever that may
mean, ecosystem surrounding it.)

My points may also be a moot point, since it seems to make this SemVer
compatible we might have to call it SemVer 1.1.0, or 2.0 depending on
how people thought the extra digit(s) would affect the compatibility
with the SemVer spec as it stands. (Is it SemVer 1.0.0 right now?)

All this being said, I like the idea of semantic versioning and I wish
more languages/software at least attempted some sort of version number
scheme transparency. #(+ 1 %) to semantic versioning.

TL;DR Can an ecosystem be properly versioned? Can that version be
cleanly expressed by the current SemVer scheme?

-- 
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


Re: Release.Next Version Number

2011-02-24 Thread Dennis Crenshaw
Inc is probably a better way to say that, yeah.

I also agree with David that 2.0 has a popular connotation of
shiny-ness that came with the whole infamous Web 2.0 branding
phenomenon.

I am now at conflict internally, because I'd like to see Clojure
widely adopted, but I like the idea of the language having the agility
to do radical things to make itself better in a way that Java no
longer posses. So 1.3 still has its advantages. Clojure always has the
choice to stay the transition to semantic versioning until Rich feels
that it's at a place that semantic versioning makes sense.

I believe I've thought myself in a circle and need some hammock time on this.

-- 
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


Re: ANN: A simple scheme interpreter in clojure

2011-01-24 Thread dennis
Thanks,it is an issue.

On Jan 24, 1:09 pm, David dsieg...@yahoo.com wrote:
 Line 86 of core.clj is:

         (list 'cadr caddr)

 and should be:

         (list 'caddr caddr)

 On Jan 23, 9:45 pm, dennis killme2...@gmail.com wrote:

  I have implemented a simple interpreter in clojure,it is just
  transformed from the interpreter in SICP.Maybe someone interested in
  it.

  I have pushed it on github athttps://github.com/killme2008/cscheme
  ,you can clone and run it by yourself.



-- 
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


Re: ANN: A simple scheme interpreter in clojure

2011-01-24 Thread dennis
Hi,
Yes,i have seen the rscheme.

cscheme is just an exercise,it is not practical at all.

On Jan 24, 1:44 pm, Andrzej ndrwr...@googlemail.com wrote:
 Hi,

 You may want to see if there is anything of interest for you 
 there:http://clojure.wikidot.com/scheme-interpreter-in-clojure

 It has its own reader that attempts to be more compatible with Scheme
 than the reader used in Clojure. It constructs a fairly elaborate
 syntactic tree (perhaps it would be better to abstract its nodes a bit
 - currently it's somewhat convoluted) and preserves a lot of
 information about the source code in metadata.

 OTOH, the evaluator is AFAIR fairly buggy and incomplete.

 The whole thing is unmaintained now so feel free to scavenge any parts
 of it, if you like.

 Cheers,

 Andrzej

 On Mon, Jan 24, 2011 at 11:45 AM, dennis killme2...@gmail.com wrote:
  I have implemented a simple interpreter in clojure,it is just
  transformed from the interpreter in SICP.Maybe someone interested in
  it.

  I have pushed it on github at
 https://github.com/killme2008/cscheme
  ,you can clone and run it by yourself.



-- 
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


ANN: A simple scheme interpreter in clojure

2011-01-23 Thread dennis
I have implemented a simple interpreter in clojure,it is just
transformed from the interpreter in SICP.Maybe someone interested in
it.

I have pushed it on github at
https://github.com/killme2008/cscheme
,you can clone and run it by yourself.

-- 
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


Vararg in protocol methods

2011-01-19 Thread dennis
I have defined a protocol with  overload methods,and one has varargs:

(ns test)
(defprotocol Say
  (say [this a] [this a  b] say hello))
(defrecord Robot []
  Say
  (say [this a] (println (str hello, a)))
  (say [this a  b] (println b)))

Then ,i new a robot and say something:
(let [ r (Robot.)]
  (say r dennis))

It worked and print hello,dennis,but if i passed more than one
arguments,it failed:

(let [ r (Robot.)]
  (say r dennis zhuang))

and threw exception

java.lang.IllegalArgumentException: No single method: say of
interface: test.Say found for function: say of protocol: Say (test.clj:
9)

It seems that clojure find methods in protocol both by name and
arity,and in this situation it found more than one methods named
say.

I don't know how to solve this problem,any suggestion? thanks a lot.

-- 
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


Why can not alter or ref-set ref after commute it?

2010-07-25 Thread dennis
Alter or ref-set a ref after commute would throw a
IllegalStateException:Can't set after commute

for example:

user= (def counter (ref 0))
#'user/counter
(dosync (commute counter inc) (ref-set counter 3))
java.lang.IllegalStateException: Can't set after commute
(NO_SOURCE_FILE:0)

I want to know why this should not happen?is it a explanation here? I
can't understand what is the difference with  commuting ref  after ref-
set or alter.Thanks a lot.

-- 
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


Improvents on agent,user-custom thread pool.

2010-07-25 Thread dennis

Agent use two thread pools to execute actions,send use a fixed thread
pool (2+cpus threads),and send-off use a cached thread pool.These
pools are global in clojure system.

I think the Agent should allow users to customize the thread pool,
if no custom,  then use the global thread pool.
   Why do I need a custom thread pool?
   First, the default thread pool is global, send use the thread pool
is a fixed size cpus +2, is likely to become the system bottleneck
sometime. Although you can use the send-off, use the cache thread
pool, but in a real world application, I can not use the cache thread
pool, which will introduce the risk of OutOfMemoryError, normally I
like to use a fixed-size thread pool.

  Second, the actions which global thread pool execute are from a
variety of agents, the actions are not homogeneous, and can not
maximize the efficient use of the thread pool, we hope that you can
specify different agent to isolate a particular thread pool to
maximize the use of thread pool .

   I think Agent could add two new functions:

(set-executor! agent (java.util.concurrent.Executors/
newFixedThreadPool 2))
(shutdown-agent agent)

set-executor! is to set the agent's custom thread pool,and shutdown-
agent to shutdown the agent's custom thread pool.



-- 
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


Re: Why can not alter or ref-set ref after commute it?

2010-07-25 Thread dennis
Thanks for your reply,Ulrich

I knew that comute would rerun before the commit,but my problem is
that if we allow ref-set ref after commuting,it seems there is no bad
thing would happen.What's the purpose of this limitation except alter
or ref-set have no lasting result?

On Jul 25, 7:01 pm, Moritz Ulrich ulrich.mor...@googlemail.com
wrote:
 Read the documentation of commute 
 carefully:http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co...

 commute acts at the end of the current dosync-block, regardless of
 when commute was applied inside it. That's the reason why you can't
 ref-set it after a commute; the commute isn't done.



 On Sun, Jul 25, 2010 at 11:19 AM, dennis killme2...@gmail.com wrote:
  Alter or ref-set a ref after commute would throw a
  IllegalStateException:Can't set after commute

  for example:

  user= (def counter (ref 0))
  #'user/counter
  (dosync (commute counter inc) (ref-set counter 3))
  java.lang.IllegalStateException: Can't set after commute
  (NO_SOURCE_FILE:0)

  I want to know why this should not happen?is it a explanation here? I
  can't understand what is the difference with  commuting ref  after ref-
  set or alter.Thanks a lot.

  --
  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

 --
 Moritz Ulrich
 Programmer, Student, Almost normal Guy

 http://www.google.com/profiles/ulrich.moritz

-- 
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


Re: Memoizing a recursive function?

2010-07-22 Thread dennis
You should make a LazySeq to momoize intermediate result:

(defn fib[n]
  (if ( n 2)
(+ (fib (- n 2)) (fib (- n 1)))
1))
(def fib (memoize fib))
(def fib-seq (map fib (iterate inc 0)))

then take the result by nth:

user= (nth fib-seq 45)
1134903170
user= (nth fib-seq 46)
1836311903
user= (nth fib-seq 47)
2971215073

The only problem is that the fib-seq would cosume more memories to
hold  intermediate result.

On Jul 22, 5:47 am, logan duskli...@gmail.com wrote:
 Lets say I have the following function

 (defn fib[n]
   (if ( n 2)
     (+ (fib (- n 2)) (fib (- n 1)))
     1))

 and I want to memoize it, what is the right way to do it?

 Using the default memoize does not work correctly. the reason is even
 though the first call to fib is memoized, the recursive calls go to
 the original fib, and not the memoized function.

 Even using

 (def fib (memoize fib))

 does not seem to work. if you run (fib 45) and (fib 46), in the ideal
 case, (fib 47) should just call the memoized (fib 45) and (fib 46) and
 return almost immediately, but that is not the case.

-- 
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


How to convert a list to arguments?

2010-07-04 Thread dennis
For example:
(max 1 2 3)  = 3
(max (list 1 2 3)) = (1 2 3)

How to convert (list 1 2 3) to arguments for function?

Thanks a lot.

-- 
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


Re: Elegant way to replace a few words in string

2010-05-29 Thread Dennis
However, in this case, the point of the code was probably to
show/teach somebody how to solve a problem.  When teaching, you want
to make the point as clear as possible, and I think John is trying to
point out, in this instance, the extra code to remove the reflection
warnings detracts from that goal.

I do not disagree with the idea of removing reflection warnings as a
rule and not an exception, especially in production software.

I should probably not fan this fire, but I did anyways... :)

-- Dennis

On Fri, May 28, 2010 at 2:45 PM, Laurent PETIT laurent.pe...@gmail.com wrote:


 2010/5/28 Michael Gardner gardne...@gmail.com

 On May 28, 2010, at 12:42 PM, Laurent PETIT wrote:

  The rule should really always be: no warning at all (with
  *warn-on-reflection* set to true, of course).

 I strongly disagree. Why should you care about those sorts of warnings
 unless you've already identified a bottleneck that needs elimination?

 Said differently than my previous answer : consider removing warnings as the
 act of keeping your code in a good state/shape. I tend to not get rid of
 warnings enough in my own java code, but for clojure production code, I
 would take warnings wayy more  seriously than e.g. java warnings.

 My 0,02€,

 --
 Laurent

 --
 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

-- 
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


Handling XML

2009-12-02 Thread Dennis
Howdy,

Being new to clojure, I am having a difficult time parsing XML in an elegant
manner.  I am pulling metric information from a ganglia server as XML and
then parsing it.  The below function works but it makes me feel icky.  I was
hoping for some tips.

The dc variable contains a map with some data center information (not
really interesting), and the stream variable comes from http.agent.

(defn handle-xml [dc stream]
  (let [xml-out (xml-seq (parse (http/stream stream)))]
(doseq [x xml-out]
  (doseq [y (:content x)]
(doseq [z (:content y)]
  (doseq [a (:content z)]
(println (:dc dc) (:NAME (:attrs z)) (:NAME (:attrs a)) (:VAL (:attrs
a)) (:TN (:attrs a)

The XML is of the form:
ganglia
  multiple clusters
multiple hosts
  multiple metrics

Example of the XML:
GANGLIA_XML VERSION=3.0.7 SOURCE=gmond
CLUSTER NAME=cluster.example.com LOCALTIME=1258396022
OWNER=unspecified LATLONG=unspecified URL=unspecified
HOST NAME=server.example.com IP=127.0.0.1 REPORTED=1258396019 TN=3
TMAX=20 DMAX=86400 LOCATION=unspe
cified GMOND_STARTED=1255757736
METRIC NAME=disk_total VAL=1320.124 TYPE=double UNITS=GB TN=6684
TMAX=1200 DMAX=0 SLOPE=both SOURCE=gmond/
METRIC NAME=cpu_speed VAL=2493 TYPE=uint32 UNITS=MHz TN=682
TMAX=1200 DMAX=0 SLOPE=zero SOURCE=gmond/
...

Thanks,
Dennis

-- 
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

Re: Handling XML

2009-12-02 Thread Dennis
Thanks, I think I have the idea.

(ns ziptest
  (:require [clojure.zip :as zip]
[clojure.xml :as xml]
[clojure.contrib.zip-filter :as zf])
  (:use clojure.contrib.zip-filter.xml)
  (:import (java.io ByteArrayInputStream)))

(def *xml-string*
a1b1c1a1b1c1/c1c2a1b1c2/c2/b1b2c1a1b2c1/c1/b2/a1)

(defn string-to-zip [s]
  (zip/xml-zip (xml/parse (ByteArrayInputStream. (.getBytes s)

(defn parse-xml [string]
  (doseq [x (xml- (string-to-zip string) zf/descendants :c1)]
(println ---  (:content (first x)

(parse-xml *xml-string*)

[dr...@drowe][h:10013][J:0] ./clojure src/ziptest.clj
---  [a1b1c1]
---  [a1b2c1]


On Wed, Dec 2, 2009 at 11:38 AM, pmf phil.fr...@gmx.de wrote:

 On Dec 2, 4:51 pm, Dennis shr3ks...@gmail.com wrote:
  The XML is of the form:
  ganglia
multiple clusters
  multiple hosts
multiple metrics

 Use XPath. Seriously, I hate XML and XSLT, but XPath is simply the
 most concise way to extract things from a nested structure. Most XPath-
 libraries allow for precompilation of XPath-expressions (similar to
 RegEx-precompilation) and don't require the whole XML-file to reside
 in memory, which makes this a nice solution for huge XML-files (though
 in your case this is probably no issue).

 To get a list of all metrics in all hosts in all clusters, you'd
 simply use the XPath-expression ganglia/cluster/host/metric against
 an XML-document; recursive fetching (if clusters could contain other
 clusters) could be done by using a double slash instead of a single
 slash.

 A Clojure-solution for a similar expression language would be
 clojure.contrib.zip-filter.xml, though I did not use it, but you might
 try it out.

 --
 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.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


-- 
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

Re: Handling XML

2009-12-02 Thread Dennis
Thanks a bunch, this has been very helpful.

-- Dennis

On Wed, Dec 2, 2009 at 1:03 PM, Tayssir John Gabbour 
tayssir.j...@googlemail.com wrote:

 BTW, I should point out that zip-filter.xml/xml- is surprisingly
 syntaxy.

 (xml- loc
:CLUSTER :HOST :METRIC
   (fn [loc]
 [[(xml1- (zip/up loc) (attr :NAME))
   (xml1- loc  (attr :NAME))
   (xml1- loc  (attr :VAL))
   (xml1- loc  (attr :TN))]]))

 In the above, I pass keywords, a function and calls to attr() to the
 xml- (and xml1-) functions. The keywords (like :CLUSTER, :HOST
 and :METRIC) expand into things like
  (tag= :CLUSTER)
 which return functions that operate on zipper objects.

 So if you're a bit overwhelmed by all the stuff that xml- accepts,
 just note that much of it is syntactic sugar, for your convenience.


 Tayssir



 On Dec 2, 7:41 pm, Tayssir John Gabbour tayssir.j...@googlemail.com
 wrote:
  Hi!
 
  Taking minor liberties with your code (for clarity), the following
  gives pretty much the same result as your handle-xml function:
 
  (ns blah
(:require [clojure.xml :as xml]
  [clojure.zip :as zip])
(:use clojure.contrib.zip-filter.xml))
 
  (defn my-test []
(doseq [x (xml- (zip/xml-zip (xml/parse /my-path-to/GANGLIA.xml))
 :CLUSTER :HOST :METRIC
 (fn [loc]
   [[(xml1- (zip/up loc) (attr :NAME))
 (xml1- loc  (attr :NAME))
 (xml1- loc  (attr :VAL))
 (xml1- loc  (attr :TN))]]))]
  (apply println x)))
 
  The call to zip/xml-zip creates a zipper object, a simple trick to
  travel around xml.
 
  Each argument to xml- (after the first) drills down the tree. The
  last argument, once I've drilled down to the :METRIC node, collects
  the attributes you're interested in.
 
  The sourcecode has handy examples to play along with. For your
  reference:
 http://github.com/richhickey/clojure-contrib/blob/81b9e71effbaf6aa294...
 
  Note: If you print the zipper object, its representation will be
  pretty, pretty big. If that's a problem, remember to call zip/node at
  the end, as per the examples. Or do the crazy thing I do, which is to
  customize print-method (specifying each zipper object's :type
  metadata), so it'll have a tiny representation like:
  #ganglia gmond
 
  Hope that makes sense,
  Tayssir
 
  On Dec 2, 4:51 pm, Dennis shr3ks...@gmail.com wrote:
 
   Howdy,
 
   Being new to clojure, I am having a difficult time parsing XML in an
 elegant
   manner.  I am pulling metric information from a ganglia server as XML
 and
   then parsing it.  The below function works but it makes me feel icky.
  I was
   hoping for some tips.
 
   The dc variable contains a map with some data center information (not
   really interesting), and the stream variable comes from http.agent.
 
   (defn handle-xml [dc stream]
 (let [xml-out (xml-seq (parse (http/stream stream)))]
   (doseq [x xml-out]
 (doseq [y (:content x)]
   (doseq [z (:content y)]
 (doseq [a (:content z)]
   (println (:dc dc) (:NAME (:attrs z)) (:NAME (:attrs a)) (:VAL
 (:attrs
   a)) (:TN (:attrs a)
 
   The XML is of the form:
   ganglia
 multiple clusters
   multiple hosts
 multiple metrics
 
   Example of the XML:
   GANGLIA_XML VERSION=3.0.7 SOURCE=gmond
   CLUSTER NAME=cluster.example.com LOCALTIME=1258396022
   OWNER=unspecified LATLONG=unspecified URL=unspecified
   HOST NAME=server.example.com IP=127.0.0.1 REPORTED=1258396019
 TN=3
   TMAX=20 DMAX=86400 LOCATION=unspe
   cified GMOND_STARTED=1255757736
   METRIC NAME=disk_total VAL=1320.124 TYPE=double UNITS=GB
 TN=6684
   TMAX=1200 DMAX=0 SLOPE=both SOURCE=gmond/
   METRIC NAME=cpu_speed VAL=2493 TYPE=uint32 UNITS=MHz TN=682
   TMAX=1200 DMAX=0 SLOPE=zero SOURCE=gmond/
   ...
 
   Thanks,
   Dennis
 
 

 --
 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.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


-- 
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

<    1   2   3