Write/reading java maps and lists using fressian/transit

2014-08-07 Thread Islon Scherer
Hi,

I have a program I wrote who needs to serialize java HashMaps and 
ArrayLists to and from disk but AFAIK (and after some simple tests) it 
seems fressian writes those maps/lists correctly but read them back as 
clojure maps and lists (persistent).
Is there a way to tell fressian (could be transit too) to read them back as 
java maps/lists?
Just for some context, it's a huge amount of data and it should be 
serialized in binary format/non-human readable way for performance and 
space considerations. All the data is composed of simple types (maps, 
lists, strings, numbers, keywords only. No complex objects)
I'm thinking about maybe just using some java serialization library if 
fressian/transit doesn't support that.

Thanks in advance.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Write/reading java maps and lists using fressian/transit

2014-08-07 Thread Islon Scherer
Ok, I got it. Instead of using transit-clj I can user the java library 
directly. The reader automatically returns ArrayList and HashMap. Great!

On Thursday, August 7, 2014 8:11:50 PM UTC+2, Thomas Heller wrote:

 Both Transit and fressian take a Handler map as arguments to the 
 reader/writer functions/constructors. So its pretty straightforward to 
 replace the default handlers with handlers that do what you want. 

 I have no example handy but it should be documented in both libraries. 
 Transit has something called mapBuilder, not sure about fressian.

 HTH,
 /thomas

 On Thursday, August 7, 2014 2:48:20 PM UTC+2, Islon Scherer wrote:

 Hi,

 I have a program I wrote who needs to serialize java HashMaps and 
 ArrayLists to and from disk but AFAIK (and after some simple tests) it 
 seems fressian writes those maps/lists correctly but read them back as 
 clojure maps and lists (persistent).
 Is there a way to tell fressian (could be transit too) to read them back 
 as java maps/lists?
 Just for some context, it's a huge amount of data and it should be 
 serialized in binary format/non-human readable way for performance and 
 space considerations. All the data is composed of simple types (maps, 
 lists, strings, numbers, keywords only. No complex objects)
 I'm thinking about maybe just using some java serialization library if 
 fressian/transit doesn't support that.

 Thanks in advance.



-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is Korma still a good current choice for DB backend?

2014-07-23 Thread Islon Scherer
Sean, that was exactly what we did when we changed to yesql. With separated 
queries our Postgres specialist could optimize each query separately, and 
for the if nesting we used cond or core.match. Even with all the 
boilerplate of maintaining separated queries it was still much better than 
Korma limited DSL. How much better yesql was compared to raw 
clojure.java.jdbc was an open question though.

On Wednesday, July 23, 2014 4:35:14 AM UTC+2, Sean Corfield wrote:

 I'm curious as to how folks using Yesql deal with conditional queries - 
 which is something we seem to run into a lot.

 For example, we have some business logic that might optionally be passed a 
 date range and maybe some other qualifier so our query would be:

 (str SELECT ... main query stuff WHERE basic conditions
 (when date-range (str  AND dateUpdated = ? AND dateUpdated  ?))
 (when qualifier  AND someColumn = ?))

 and then some conditions to build the parameters:

 (cond- basic-params
 date-range (concat date-range)
 qualifier (concat [qualifier]))

 It seems like with Yesql we'd have to have four different query functions 
 and then code like this:

 (if date-range
 (if qualifier
 (query-with-date-range-and-qualifier db basic params (first date-range) 
 (second date-range) qualifier)
 (query-with-date-range db basic params (first date-range) (second 
 date-range)))
 (if qualifier
 (query-with-qualifier db basic params qualifier)
 (query-basic db basic params)))

 Sean

 On Jul 22, 2014, at 6:08 AM, Timothy Baldridge tbald...@gmail.com 
 javascript: wrote:

 Also, read the rationale behint yesql: 
 https://github.com/krisajenkins/yesql IMO, it hits the nail on the head. 
 ORMs are both crappy object systems and crappy DB DSLs. With a library like 
 yesql you write your queries in pure SQL and get pure data back. Now you 
 can fully leverage both SQL and Clojure. 




-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Meta-eX - The Music of Code

2014-04-14 Thread Islon Scherer
Overtone is amazing, I'm planning on doing some experiments with it as soon 
as I finish the supercollider book and improve my music theory skills.

On Friday, April 11, 2014 4:44:22 PM UTC+2, Sam Aaron wrote:


 On 10 Apr 2014, at 03:18, Earl Jenkins ejenk...@gmail.com javascript: 
 wrote: 

  Good stuff, all the hard work you've done in the field of live coding, 
 yet no mention of Meta-ex nor clojure in the Computer Music Journal which 
 has a whole issue dedicated to this subject  ;( 

 To be honest, Overtone was never targeted at academics. It was built for 
 Clojure hackers to be able to use their programming skills to realise their 
 musical ideas. As such, it's gained a lot of traction with progressional 
 programmers. 

 I'm continuously amazed with what people are doing with Overtone - 
 stretching it in incredible ways. However, I feel that the best is still 
 yet to come. Now is a fantastic time to get involved... 

 Sam 

 --- 
 http://sam.aaron.name

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Latest web framework for clojure

2014-02-28 Thread Islon Scherer
If you are learning go with a simple approach (compojure + http-kit + 
hiccup for example). If you already know clojure I recommend going with 
some library that provide everything as data, specially the routes, as the 
function composition approach of compojure only gets you so far (been 
there).

On Friday, February 28, 2014 12:05:08 PM UTC+1, xavi wrote:

 I would recommend this combination of libraries:

 - Compojure
 - lib-noir
 - Enlive and Enfocus, for server-side and client-side templating 
 respectively (I've also used Hiccup, but I prefer Enlive/Enfocus because 
 with these, templates are pure HTML; I prefer them even for solo projects, 
 but I would especially recommend them if the HTML/CSS is going to be 
 written by people that don't necessarily know anything about 
 Clojure/ClojureScript).
 - CongoMongo, if you're using MongoDB as a database (there's also Monger, 
 but I don't have any experience with it)

 Some time ago I open-sourced a base web, with a complete authentication 
 system, that used these libraries. Maybe you'll find it useful
 https://github.com/xavi/noir-auth-app

 Cheers,
 Xavi

 On Thursday, February 27, 2014 2:57:07 AM UTC+1, Moritz Ulrich wrote:

 Om is well-suited to handle the UI-part for you. It doesn't do any 
 server communication or forces you into any particular programming 
 style or project layout. 

 On Thu, Feb 27, 2014 at 2:35 AM, Mark Engelberg 
 mark.en...@gmail.com wrote: 
  As far as I can tell, neither luminus nor caribou are well-suited to 
  building, for example, interactive web apps like this web-based chat 
 room 
  which serves as the Hello World for the Opa web framework: 
  https://github.com/MLstate/opalang/wiki/Hello%2C-chat 
  
  Is this the kind of thing that Pedestal and Hoplon are meant for?  Or 
 Om? 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from it, send 
 an 
  email to clojure+u...@googlegroups.com. 
  For more options, visit https://groups.google.com/groups/opt_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.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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Do web apps need Clojure?

2013-11-14 Thread Islon Scherer
For me it's about 1 thing: Data.

A web application is about taking data from the user, transform it and 
store it on the database and take data from the database, transform it and 
show it to the user.
Clojure is the best language I used to work with data, it just gives you a 
composable set of tools and then get out of your way, and there's always 
macros for the more complex use cases.
We have a web application that serves edn data to our clojurescript 
frontend, our webdevelopers created a new site for mobile in backbone.js 
that used json, I had just to create a function (ring middleware) that 
transformed my edn data to json based on the accept header.

My 2¢

On Thursday, November 14, 2013 9:11:04 AM UTC+1, Bastien Guerry wrote:

 Marcus Blankenship mar...@creoagency.com javascript: writes: 

  Brian, that’s really interesting.  I think we’re seeing something 
  similar, and are going to look at Pedestal and Caribou as options for 
  a project we’re working on.  Are their others we should consider? 

 Perhaps you should consider starting from scratch, in parallel. 

 Maybe that's because I'm a beginner in both the language and in web 
 development, but so far I've found it's the best way to understand the 
 choices behind framaworks.  Otherwise I would confuse web development 
 with those choices, and I feel the richness of the Clojure ecosystem 
 is precisely to open your mind about web development. 

 2 cents, 

 -- 
  Bastien 


-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: wally: a alternative way to discover functions

2013-09-09 Thread Islon Scherer
Florian: I filter out all functions that end with ! but I can't know for 
sure which functions have side effects.

On Sunday, September 8, 2013 7:24:48 AM UTC+2, Florian Over wrote:

 Hi,
 you could check for io! to find forms with side-effect, but i think it is 
 seldom used.
 Florian

 http://clojuredocs.org/clojure_core/clojure.core/io!


 2013/9/8 Maximilien Rzepka maximili...@gmail.com javascript:

 Found many times apropos useful...
 user (apropos partition)
 (partition-by partition-all partition)

 But wally approach is really cool.
 Thanks for sharing 
 @maxrzepka

 Le jeudi 5 septembre 2013 23:23:28 UTC+2, Islon Scherer a écrit :

 Hey guys,

 I don't know about you but when I was a beginner in Clojure (and it 
 still happens every now and then) I had a hard time finding functions using 
 `doc` or `find-doc`,
 normally because I didn't remember the name of the function or because 
 my only clue was a generic name so find-doc would return too much results. 
 But one
 thing I knew: what to expect of the function, I knew the inputs and the 
 outputs. That's why I decided to create wally, because sometimes you don't
 know the name of the function you want but you know how it should behave.

 With wally you can tell the inputs and the output and it'll search for 
 functions that match those inputs/outputs.

 Ex:

 user= (find-by-sample {1 1, 2 3, 3 1, 4 2} [1 2 3 4 4 2 
 2])-clojure.core/frequencies([coll])
   Returns a map from distinct items in coll to the number of times
   they appear.


 user= (find-by-sample '((1 2 3) (4 5)) (partial  3) [1 2 3 4 5])
 -
 clojure.core/partition-by
 ([f coll])
   Applies f to each value in coll, splitting it each time f returns
a new value.  Returns a lazy seq of partitions.


  
 https://github.com/**stackoverflow/wallyhttps://github.com/stackoverflow/wally

  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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 unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_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.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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: wally: a alternative way to discover functions

2013-09-07 Thread Islon Scherer


 I wonder if it would be possible to improve it using the core.typed 
 library and doing some kind of static analysis similar to Haskell's Hoogle 
 to filter out candidates.

The problem is most Clojure functions don't use core.type nor are type 
annotated.
It would be nice if pure functions had some metadata like :pure true. =) 

On Saturday, September 7, 2013 1:53:08 AM UTC+2, Chris-tina Whyte wrote:

 Interesting!

 Though it executes every function in order to find the matches, which is a 
 little bit dangerous as Clojure doesn't enforce purity :( 

 I wonder if it would be possible to improve it using the core.typed 
 library and doing some kind of static analysis similar to Haskell's Hoogle 
 to filter out candidates.

 On Thursday, September 5, 2013 6:23:28 PM UTC-3, Islon Scherer wrote:

 Hey guys,

 I don't know about you but when I was a beginner in Clojure (and it still 
 happens every now and then) I had a hard time finding functions using `doc` 
 or `find-doc`,
 normally because I didn't remember the name of the function or because my 
 only clue was a generic name so find-doc would return too much results. But 
 one
 thing I knew: what to expect of the function, I knew the inputs and the 
 outputs. That's why I decided to create wally, because sometimes you don't
 know the name of the function you want but you know how it should behave.

 With wally you can tell the inputs and the output and it'll search for 
 functions that match those inputs/outputs.

 Ex:

 user= (find-by-sample {1 1, 2 3, 3 1, 4 2} [1 2 3 4 4 2 
 2])-clojure.core/frequencies([coll])
   Returns a map from distinct items in coll to the number of times
   they appear.


 user= (find-by-sample '((1 2 3) (4 5)) (partial  3) [1 2 3 4 5])
 -
 clojure.core/partition-by
 ([f coll])
   Applies f to each value in coll, splitting it each time f returns
a new value.  Returns a lazy seq of partitions.


  https://github.com/stackoverflow/wally



-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: wally: a alternative way to discover functions

2013-09-06 Thread Islon Scherer
Mayank: thanks!

Shaun: I thought about approximations too but that's enough complexity to 
be another library by itself.
If there's such a library that I can feed two values and it returns how 
similar they are with some percentage I would gladly integrate it with 
wally.

Of course wally only works for referential transparent/pure functions but 
that's the majority of Clojure functions anyway =)

On Friday, September 6, 2013 6:44:43 AM UTC+2, Shaun Gilchrist wrote:

 Very cool! I wonder how hard it would be to have it suggest compositions 
 if it can not find a direct match? 


 On Thu, Sep 5, 2013 at 10:34 PM, Mayank Jain fires...@gmail.comjavascript:
  wrote:

 Looks pretty interesting. Thanks for sharing


 On Fri, Sep 6, 2013 at 2:53 AM, Islon Scherer 
 islons...@gmail.comjavascript:
  wrote:

 Hey guys,

 I don't know about you but when I was a beginner in Clojure (and it 
 still happens every now and then) I had a hard time finding functions using 
 `doc` or `find-doc`,
 normally because I didn't remember the name of the function or because 
 my only clue was a generic name so find-doc would return too much results. 
 But one
 thing I knew: what to expect of the function, I knew the inputs and the 
 outputs. That's why I decided to create wally, because sometimes you don't
 know the name of the function you want but you know how it should behave.

 With wally you can tell the inputs and the output and it'll search for 
 functions that match those inputs/outputs.

 Ex:

 user= (find-by-sample {1 1, 2 3, 3 1, 4 2} [1 2 3 4 4 2 
 2])-clojure.core/frequencies([coll])
   Returns a map from distinct items in coll to the number of times
   they appear.


 user= (find-by-sample '((1 2 3) (4 5)) (partial  3) [1 2 3 4 5])
 -
 clojure.core/partition-by
 ([f coll])
   Applies f to each value in coll, splitting it each time f returns
a new value.  Returns a lazy seq of partitions.


  https://github.com/stackoverflow/wally
  
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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 unsubscribe from this group and stop receiving emails from it, send 
 an email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




 -- 
 Regards,
 Mayank. 

 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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 unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_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.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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: wally: a alternative way to discover functions

2013-09-06 Thread Islon Scherer
Thanks for the gist, nice solution but it's not viable for real world code 
without some heavy filtering. If I execute it on my current project it 
starts a server, sends a bunch of emails and hangs forever =)

On Friday, September 6, 2013 2:12:29 PM UTC+2, Frantisek Sodomka wrote:

 Hello,
 this gist does the similar thing:
 https://gist.github.com/jaked/6084411

 Maybe you can find some inspiration in it.

 Frantisek


 On Thursday, September 5, 2013 11:23:28 PM UTC+2, Islon Scherer wrote:

 Hey guys,

 I don't know about you but when I was a beginner in Clojure (and it still 
 happens every now and then) I had a hard time finding functions using `doc` 
 or `find-doc`,
 normally because I didn't remember the name of the function or because my 
 only clue was a generic name so find-doc would return too much results. But 
 one
 thing I knew: what to expect of the function, I knew the inputs and the 
 outputs. That's why I decided to create wally, because sometimes you don't
 know the name of the function you want but you know how it should behave.

 With wally you can tell the inputs and the output and it'll search for 
 functions that match those inputs/outputs.

 Ex:

 user= (find-by-sample {1 1, 2 3, 3 1, 4 2} [1 2 3 4 4 2 
 2])-clojure.core/frequencies([coll])
   Returns a map from distinct items in coll to the number of times
   they appear.


 user= (find-by-sample '((1 2 3) (4 5)) (partial  3) [1 2 3 4 5])
 -
 clojure.core/partition-by
 ([f coll])
   Applies f to each value in coll, splitting it each time f returns
a new value.  Returns a lazy seq of partitions.


  https://github.com/stackoverflow/wally



-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


wally: a alternative way to discover functions

2013-09-05 Thread Islon Scherer
Hey guys,

I don't know about you but when I was a beginner in Clojure (and it still 
happens every now and then) I had a hard time finding functions using `doc` 
or `find-doc`,
normally because I didn't remember the name of the function or because my 
only clue was a generic name so find-doc would return too much results. But 
one
thing I knew: what to expect of the function, I knew the inputs and the 
outputs. That's why I decided to create wally, because sometimes you don't
know the name of the function you want but you know how it should behave.

With wally you can tell the inputs and the output and it'll search for 
functions that match those inputs/outputs.

Ex:

user= (find-by-sample {1 1, 2 3, 3 1, 4 2} [1 2 3 4 4 2 
2])-clojure.core/frequencies([coll])
   Returns a map from distinct items in coll to the number of times
   they appear.


user= (find-by-sample '((1 2 3) (4 5)) (partial  3) [1 2 3 4 5])
 -
 clojure.core/partition-by
 ([f coll])
   Applies f to each value in coll, splitting it each time f returns
a new value.  Returns a lazy seq of partitions.


 https://github.com/stackoverflow/wally

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Multiple REPLs in Emacs? (was: test run startup time

2013-07-12 Thread Islon Scherer
Here at doo we have a shortcut C-c X where X is a number to change 
between nrepls.

The code is in https://github.com/maxweber/emacs.d/blob/master/my/nrepl.el

Note that the nrepl ports are hardcoded but it's good enough for us.

Hope this helps.

--
Islon

On Thursday, July 11, 2013 11:53:31 PM UTC+2, Sean Corfield wrote:

 On Wed, Jul 10, 2013 at 10:53 AM, Jay Fields 
 j...@jayfields.comjavascript: 
 wrote: 
  I work in emacs with 2 repls running - 1 for running my app and 1 for 
  running my tests. 

 What is the magic to get this working and how does Emacs / nrepl.el 
 know which REPL to send commands to? 

 I've often wanted multiple active REPLs (usually for working with 
 multiple projects) but have never figured out how to get it working... 
 -- 
 Sean A Corfield -- (904) 302-SEAN 
 An Architect's View -- http://corfield.org/ 
 World Singles, LLC. -- http://worldsingles.com/ 

 Perfection is the enemy of the good. 
 -- Gustave Flaubert, French realist novelist (1821-1880) 


-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Functions that return seqs

2013-07-02 Thread Islon Scherer
One things that always bugged me about clojure is that most functions that 
work on collections return seqs and not the original data structure type:

(= [2 4 6] (- [2 [4]] flatten (conj 6)))
= false

Every time I transform collections I need to be aware of this.
My questions is: is there a philosophical reason for that or it was 
implement this way because it's easier? Why conj is different?
Doesn't it break the principle of least surprise?

Thanks,
Islon

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Functions that return seqs

2013-07-02 Thread Islon Scherer
Thanks for all the answers.
Agreed that sequences are a great abstraction (100 functions in 1 data 
structure instead of 10 to 10) and, as David said, there's value in having 
the return type to be predictable.
I think a 'generics collection functions' library would be nice for those 
edge cases you want those functions to be generic.

I guess the philosophical reason is that 'concrete types don't 
 really matter'... 

Well, maybe most of the time, but there's cases where the concrete type 
semantics matters a lot, specially with sets but sometimes with vectors 
too, right now i'm using into or just calling vec|set or reducers library 
but maybe I'll try to implement this generics library I just talk about as 
it's really easy to do that in clojure =)

Islon

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Lambda: A lniux distro for clojurists

2012-05-26 Thread Islon Scherer
Why not create a shell script?

On May 26, 9:32 am, Denis Labaye denis.lab...@gmail.com wrote:
 Hi,

 This is a very interesting idea. It would have been of great use when I
 did a Clojure workshop with complete beginners, with all kinds of OSes
 (Windows, OSX, ...).

 I took the Completely packaged VirtualBox image approach, but it is
 still a big mess: Not everyone have VirtualBox installed (or the right
 version). And not every flavors of the main editors where correctly
 configured for Clojure (Emacs, vi).

 Being able to just boot on a live CD, and have a working Clojure
 environment would have been great. Also great for distribution: Just
 burn it on a lot of cheap Cd's, and much more down loadable: A Virtual
 Box image takes about 2gig, a live CD is 700meg.

 Cheers,

 Denis

 On Thu, May 24, 2012 at 10:11 PM, banseljaj ali.sajid.im...@gmail.comwrote:







  Hello Guys,

  I am quite new to clojure, and I am a fan. It's a great thing. One thing
  that seems missing, however, is a single unified way of setting up the
  clojure environment. Which seemed pretty daunting to me at first.

  So I have decided to create a Linux Distro specifically for Clojure
  development.

  I have been bouncing this idea in #clojure and it got a good response. So
  now I have started the complete development effort.

  My plan so far is as follows.

  Mission Statement for the Distro

  The distro should be able to:

     - Connect to internet.
     - Be able to convert itself into An VM/Iso/LiveCD etc
     - Have all IDEs for Clojure installed and preconfigured.
        - Eclipse
        - Vim
        - Emacs
        - Netbeans
     - Have a ready to play connection to clojure forums and channels
     - Have at-least one book on clojure programming on board
     - Have following clojure specific features
        - It should have leiningen installed and configured
        - It should have a local repo of all current clojure plugins
        - It should have a local cloud on which you can deploy web apps
        easily
        - it should have REPLlabs on baord and configured
     - Have Clojure specific branding

  The packages that are needed absolutely:

     - OpenJDK 1.7.0
     - Leiningen
     - Clojure
     - Eclipse
     - Vim
     - Emacs 24
     - Netbeans
     - Emacs Starter kit
     - CCW plugin for eclipse
     - Firefox/Chrome
     - A local webserver
     - Postgresql
     - LXDE/XFCE
     - Gwibber/Other Social network Client
     - xchat
     - irssi
     - git
     - Regular packages for system functioning.

  I am still open to ideas. I intend to roll it as a complete distro, so I
  will love any and all input.

  For now, the specific things I need input for are:

     - Who/How to create the art for branding.
     - Any packages that are missing from the above listing.
     - Any suggestions for the overall functioning.

  I will soon have an actual website set up.

  It is my intention to create a fully functional, independent Development
  environment for Functional programmers by release 2. Right now, I am
  working on release 0.0.1.

  Looking forward to all input.

  regards.

  banseljaj

   --
  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: Sum on a list of maps

2011-10-14 Thread Islon Scherer
The best i could think was:

 (defn calc-types [coll]
  (let [types (map (fn [m] {:type (get m Type) :value (Double/parseDouble 
(get m Value))}) coll)  ; convert keys to keywords and values to doubles
it1 (sort-by :type types) ; sort by type
a (atom (:type (first it1)))
it2 (partition-by (fn [m] (if (not= (:type m) @a) (do (reset! a 
(:type m)) true) false)) it1)] ; partition by type
(map (fn [l] {:type (:type (first l)), :value (reduce + (map :value 
l))}) it2))) ; map reduce

Hope it helps.
P.S: Try to use keywords and numbers instead of strings, the function will 
be simpler

-- 
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: Learning clojure - comments on my function?

2011-09-29 Thread Islon Scherer
You probably want something like

(defn split-zero [ls]
(filter #(not= (first %) 0) (partition-by zero? ls)))

-- 
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: suggestion for clojure development

2011-09-28 Thread Islon Scherer
I agree with Nicolas, clojure should, at this point, focus on improving the 
language instead of maintain compatibility, and as most features of other 
languages can be implemented as macros I think clojure is ahead of the 
competition.

-- 
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: lein repl newbie question

2011-09-23 Thread Islon Scherer
Have you tried control+d?

-- 
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: Re: lein repl newbie question

2011-09-23 Thread Islon Scherer
control+d exits clojure repl

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

Re: Top secret clojure project names

2011-09-01 Thread Islon Scherer
I have a big clojure project at work but it's not a secret. It
superseded a old java project, the clojure one is 50 times smaller, 10
times faster and bug free. They had no choice but to accept the new
one =)

On Sep 1, 6:54 pm, Sean Corfield seancorfi...@gmail.com wrote:
 On Thu, Sep 1, 2011 at 2:31 PM, JAX jayunit...@gmail.com wrote:
  Hi guys: I assume some of you have secret Clojure projects at work, that 
  your bosses don't know about.

 LOL! That would be hard for me - every commit and every ticket update
 / comment is emailed to the whole project team which includes
 management :)

 It does pose an interesting question tho': how many folks are using
 skunkwork projects to introduce Clojure vs opening getting buy in up
 front?
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View --http://corfield.org/
 World Singles, LLC. --http://worldsingles.com/
 Railo Technologies, Inc. --http://www.getrailo.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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: learning clojure library

2011-08-03 Thread Islon Scherer
You can use (ns-publics 'your.namespace) to see every public intern mapping 
in this namespace.

Islon

-- 
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: Code structure/design problems

2011-07-28 Thread Islon Scherer
Hi Oskar, I've been a game programmer for more than 5 years going from 
simple card games to 3D MMORPGs.
Even though you can make a simple game in a functional way it would be a big 
challenge to do the same with a moderately complex game.
Games are all about state, your character if full of state, the enemies have 
state, the world, the AI, the physics, etc.
If you're creating a complex game the language you chose is the least of 
your concerns, the graphics engine, physics engine, AI engine is what really 
matters.
I'm not saying you can't create a game in clojure(I already did) and if your 
main objective is to learn clojure go ahead, but don't be afraid to model 
stateful entities.
However, if you're thinking about making a complex/commercial game I 
strongly advise you use a game engine, there are good free game engines out 
there and it will make your game 2 or 3 orders of magnitude faster to 
finish.

Islon

-- 
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: Need Help Parsing Clojure Strings

2011-07-25 Thread Islon Scherer
Do you want something like:
(vec (.split some-string \\|))

(vec (.split AT|1 Kenilworth Rd||Soapville|ZA|99901-7505|Option value=A == 
Normal street matchOption value=T == ZIP+4 corrected|013|C065| \\|))
= [AT 1 Kenilworth Rd  Soapville ZA 99901-7505 Option value=A 
== Normal street matchOption value=T == ZIP+4 corrected 013 C065]

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

JSON library for clojure 1.3

2011-07-22 Thread Islon Scherer
Is there a clojure json library that works in clojure 1.3?
I tried danlarkin/clojure-json but it gives me error: 
java.lang.IllegalArgumentException: Unable to resolve classname: 
IPersistentMap, compiling:(org/danlarkin/json/encoder.clj:144)

-- 
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: JSON library for clojure 1.3

2011-07-22 Thread Islon Scherer
Thanks Sean, org.clojure/data.json worked like a charm.

-- 
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: JSON library for clojure 1.3

2011-07-22 Thread Islon Scherer
I'll take a look, but I only need basic json encoding/decoding right now.

Islon

-- 
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: Being able to use blank?

2011-07-21 Thread Islon Scherer
I think it's just a sintax problem.

(ns test-csv
  ...
  (:require [clojure.string :as str]))

-- 
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: How to Return Vector of Vectors

2011-07-21 Thread Islon Scherer
Simple: conj doesn't mutate the vector, it returns a new vector.
Clojure is a (mostly) immutable language, you're trying to solve the
problem in a imperative way, you should solve it in a functional way.

On Jul 21, 7:48 pm, octopusgrabbus octopusgrab...@gmail.com wrote:
 (def accumail-url-keys [CA, STREET, STREET2, CITY, STATE,
 ZIP, YR, BILL_NO, BILL_TYPE])

 (defn ret-params
     Generates all q-parameters and returns them in a vector of
 vectors.
     [all-csv-rows]
     (let [param-vec [[]] ]
         (doseq [one-full-csv-row all-csv-rows]
             (let [accumail-csv-row one-full-csv-row
                   q-param (zipmap accumail-url-keys accumail-csv-row)
                   accu-q-param (first (rest (split-at 3 q-param)))
                   billing-param (first (split-at 3 q-param))]
                 (conj param-vec accu-q-param billing-param)))
          param-vec))

 I combine some internal data with each vector returned from clojure-
 csv's parse-csv. I want to return all that in a new vector of vectors,
 but param-vec is empty. What am I doing wrong?

 tnx
 cmn

-- 
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: Fixing Java Apache Class error

2011-07-20 Thread Islon Scherer
Mark is right, you should use lein (or cake) repl instead of trying to run 
clojure on command line.

-- 
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 on Google+ yet?

2011-07-14 Thread Islon Scherer
http://gplus.to/islonscherer

On Jul 14, 8:55 pm, Sean Corfield seancorfi...@gmail.com wrote:
 On Thu, Jul 14, 2011 at 4:00 PM, ianp ian.phill...@gmail.com wrote:
  Looks like G+ is pretty popular with the Clojure crowd :-)

 I've been using it for a while and I don't see the point. With
 Facebook for *friends* and Twitter for tech talk (and LinkedIn for
 professional networking), what purpose does G+ have?

 I just found it annoying. I recently turned off all email
 notifications and deleted everyone from my circles and disabled most
 of the features and now, apart from the occasional annoying red
 notification icon in Gmail, I can completely ignore it.

 Is it just a case of ooh, shiny! Google released a new toy! or is
 there actually some tangible useful benefit to a developer being on
 G+?
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View --http://corfield.org/
 World Singles, LLC. --http://worldsingles.com/
 Railo Technologies, Inc. --http://www.getrailo.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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 for large programs

2011-07-04 Thread Islon Scherer
I think  the issue with large programs is not the language but
software engineering.
A large program should be well designed and architected, and this is a
problem (I think) many
people in clojure and functional programming in general have. Clojure
is a very high level and concise language so I'll grow my program as I
type.
I'm not proposing UML or any specific tool or technique, but analysis
and design are a important part of a large software.
It's easier to understand your problem if you look at your high level
documentation/diagrams than look at code. Of course some problems and
refactor
will happen no matter how well you designed, but you'll understand
better what you did and what you should do.

Islon

On Jul 4, 9:40 am, James Keats james.w.ke...@gmail.com wrote:
 On Jul 4, 1:26 pm, James Keats james.w.ke...@gmail.com wrote:

  On Jul 4, 5:45 am, Christian Schuhegger
  A good
  book to get you started would SEMANTIC WEB for the WORKING ONTOLOGIST,
  of which a second edition has recently come out. :-)

 Sorry about the unintentional to get you started figure of speech; I
 note you said you already had rdf/owl in your kit. It's not out of
 underestimating your knowledge (though it might be out of my sense of
 being mildly overwhelmed by the still remaining reading list I already
 have of semantic web books, Springer just keeps dropping them like
 rain. :-)

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


date-clj clojure date/time library

2011-06-29 Thread Islon Scherer
Hello people.
I've created date-clj, a date/time library for clojure.
I know there's clj-time already but I was thinking about something
less javaish and more like date.js.

Some examples:

(date :day 25 :month :november :year 2000)
- #Date Sat Nov 25 00:00:00 BRST 2000

(- (today) (set-date :month :december :year 1900))
- #Date Sat Dec 29 16:44:33 BRST 1900

(from-now 1 :year 5 :days)
- #Date Wed Jul 04 16:44:33 BRST 2012

(back 1 :month 200 :minutes)
- #Date Sun May 29 13:26:33 BRST 2011

(following :friday)
- #Date Fri Jul 01 16:47:17 BRST 2011

(- (today) (is? :friday 13))
- false

(- (back 3 :days) (was? :sunday))
- true

(- (april) sundays first)
- #Date Sun Apr 03 00:00:00 BRST 2011

(- (following :month) fridays last)
- #Date Fri Jul 29 00:00:00 BRST 2011

(monday)
- #Date Mon Jun 27 00:00:00 BRST 2011

(binding [*locale* (Locale/GERMAN)] (names :week-days))
- (Sontag Montag Dienstag Mittwoch Donnerstag Freitag
Samstag)


The project page is: http://github.com/stackoverflow/date-clj

Critics and ideas are welcome =)
Regards,
Islon

-- 
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: date-clj clojure date/time library

2011-06-29 Thread Islon Scherer
Thanks for the critic Laurent.
set-date is not destructive, it creates a new date and returns it, the
original is unaltered,
but I agree that the documentation and the function name may be
deceiving, I'll think about a better name and change the docs.

Islon

On Jun 29, 5:29 pm, Laurent PETIT laurent.pe...@gmail.com wrote:
 Or to be more constructive:

 maybe set-date al should be renamed set-date! ...

 ... the more clojurish a library will look like, the more
 expectations people will have on it (principle of least surprise) even
 before verifying their assumptions are true (e.g. a pure clojure
 library = works with immutable -if not persistent- datastructures)

 My 0.02€,

 --
 Laurent

 2011/6/29 Islon Scherer islonsche...@gmail.com:







  Hello people.
  I've created date-clj, a date/time library for clojure.
  I know there's clj-time already but I was thinking about something
  less javaish and more like date.js.

  Some examples:

  (date :day 25 :month :november :year 2000)
  - #Date Sat Nov 25 00:00:00 BRST 2000

  (- (today) (set-date :month :december :year 1900))
  - #Date Sat Dec 29 16:44:33 BRST 1900

  (from-now 1 :year 5 :days)
  - #Date Wed Jul 04 16:44:33 BRST 2012

  (back 1 :month 200 :minutes)
  - #Date Sun May 29 13:26:33 BRST 2011

  (following :friday)
  - #Date Fri Jul 01 16:47:17 BRST 2011

  (- (today) (is? :friday 13))
  - false

  (- (back 3 :days) (was? :sunday))
  - true

  (- (april) sundays first)
  - #Date Sun Apr 03 00:00:00 BRST 2011

  (- (following :month) fridays last)
  - #Date Fri Jul 29 00:00:00 BRST 2011

  (monday)
  - #Date Mon Jun 27 00:00:00 BRST 2011

  (binding [*locale* (Locale/GERMAN)] (names :week-days))
  - (Sontag Montag Dienstag Mittwoch Donnerstag Freitag
  Samstag)

  The project page is:http://github.com/stackoverflow/date-clj

  Critics and ideas are welcome =)
  Regards,
  Islon

  --
  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: Clojure ideas repository / todo list

2011-05-15 Thread Islon Scherer
Good ideas, I'm thinking about implementing it as my first clojure web
project.

Thanks!

-- 
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 ideas repository / todo list

2011-05-14 Thread Islon Scherer
Is there anyplace people post ideas of libraries/frameworks/functions
that would be nice to be implemented in clojure?
Sometimes I want to help the community but I don't know what to do (an
idea), what's already done (yeah, I know one can search github or ask
here but you can't be 100% sure it's not already implemented). Maybe a
wiki or something like that would do the job.

Thanks in advance,
Islon

-- 
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: Learning Idiomatic Clojure

2011-05-12 Thread Islon Scherer
Read the joy of clojure, it's an amazing book that will teach you the
way of clojure.

Islon

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


problem running tests in leiningen

2011-05-06 Thread Islon Scherer
I have a lein project and I'm trying to run my tests with lein test.
The first problem I had was a class not found error in one of my
records
so I put aot: [namespace.name] in project.clj.
It's required that I put all namespaces that contain defrecords/
deftypes in the aot list?

After that I tried to run the tests again and got a different error:
Exception in thread main java.lang.ClassNotFoundException:
clojure.pprint
Inside lein swank this code runs and compiles with no problems, do
lein
execute tests with a different clojure(and/or contrib) version?

This is my project.clj

(defproject mediaretriever 1.0.0-SNAPSHOT
  :description ...
  :dependencies [[org.clojure/clojure 1.2.1]
 [org.clojure/clojure-contrib 1.2.0]
 [enlive 1.0.0]
 [clj-http 0.1.3]
 [clj-time 0.3.0]]
  :dev-dependencies [[swank-clojure 1.3.0]]
  :aot [mediaretriever.media])

Any help is appreciated.
Regards
Islon

-- 
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: Search for a node querying on attrs

2011-05-06 Thread Islon Scherer
This is what I did:

(let [nodes (html/html-resource (StringReader. body))
   meta-extractor (fn [m attr] (first (filter #(= (-
% :attrs :name) attr) m)))
   metas (html/select nodes [:meta])
   title (- (meta-extractor metas title) :attrs :content)
   desc (- (meta-extractor metas description) :attrs :content)
   date-raw (- (meta-extractor metas date) :attrs :content)
   keywords-raw (- (meta-extractor metas
keywords) :attrs :content)
   keywords (string/split keywords-raw #, )]

Hope it helps.

On May 5, 5:18 am, Alfredo alfredo.dinap...@gmail.com wrote:
 Ty very much :)
 Alfredo

 On May 5, 10:05 am, Thorsten Wilms t...@freenet.de wrote:







  On 05/04/2011 06:23 PM, Alfredo wrote:

   meta name=keywords content=clojure, is, good /

   I want to extract only the content part.

  I recently had related issues, so:

  (def metas
     (en/html-snippet
       meta http-equiv=\Content-Type\ content=\text/html;
          charset=UTF-8\ /
        meta name=\keywords\ content=\clojure, is, good\ /))

  (en/select metas [[:meta (en/attr= :name keywords)]])

  (- (en/select metas [[:meta (en/attr= :name keywords)]])
       first :attrs :content)

  --
  Thorsten Wilms

  thorwil's design for free software:http://thorwil.wordpress.com/

-- 
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: problem running tests in leiningen

2011-05-06 Thread Islon Scherer
Thanks Stuart, the tests are working now.

On May 6, 12:16 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:
  I have a lein project and I'm trying to run my tests with lein test.
  The first problem I had was a class not found error in one of my
  records
  so I put aot: [namespace.name] in project.clj.
  It's required that I put all namespaces that contain defrecords/
  deftypes in the aot list?

 This should not be a requirement. However, you might need to require the 
 namespace containing the class before using the class.

  After that I tried to run the tests again and got a different error:
  Exception in thread main java.lang.ClassNotFoundException:
  clojure.pprint
  Inside lein swank this code runs and compiles with no problems, do
  lein
  execute tests with a different clojure(and/or contrib) version?

 The standard Clojure repl uses some utility fns from non-core namespaces. 
 Specifically:

      ;; from main.clj
      (use '[clojure.repl :only (source apropos dir pst doc find-doc)])
      (use '[clojure.java.javadoc :only (javadoc)])
      (use '[clojure.pprint :only (pp pprint)])

 When you run code outside the REPL, you will need to use these specifically 
 if you need them.

 Hope this helps.

 Stu

 Stuart Halloway
 Clojure/corehttp://clojure.com

-- 
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: record serialization

2010-11-24 Thread Islon Scherer
Thanks for the answers!
Some guy told me on irc that you can implement interfaces right in the
record definition like
(defrecord R [a b] SomeInterface (methods...))

Regards.
Islon

On Nov 24, 4:25 am, Shantanu Kumar kumar.shant...@gmail.com wrote:
 Shantanu Kumar wrote:
  Islon Scherer wrote:
   Yes, java serialization is what I want but I don't know how to do a
   record implement the Serializable interface.

  The following two steps may help:

  (defrecord Foo [a b])
  (extend java.io.Serializable Foo)

 Oops! that was a bit too fast. Records already implement Serializable.

 Regards,
 Shantanu

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


record serialization

2010-11-23 Thread Islon Scherer
Hi people, I want to serialize records to further deserializing, is
there a way to do that?
(pr-str myrecord) doesn't seen to work.
I was thinking about something like (to-map record) and (from-map
RecordClass record) to serialize and deserialize.
Any sugestions?

Islon

-- 
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: record serialization

2010-11-23 Thread Islon Scherer
Yes, java serialization is what I want but I don't know how to do a
record implement the Serializable interface.

On Nov 23, 2:46 pm, Shantanu Kumar kumar.shant...@gmail.com wrote:
 Not sure about your exact requirement, but can Java serialization
 help? You may need to extend the Serializable interface to the
 records.http://java.sun.com/developer/technicalArticles/Programming/serializa...

 Regards,
 Shantanu

 On Nov 23, 5:50 pm, Islon Scherer islonsche...@gmail.com wrote:







  Hi people, I want to serialize records to further deserializing, is
  there a way to do that?
  (pr-str myrecord) doesn't seen to work.
  I was thinking about something like (to-map record) and (from-map
  RecordClass record) to serialize and deserialize.
  Any sugestions?

  Islon

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

2010-08-05 Thread Islon Scherer
Ok, this question is not about clojure itself, just a doubt I have.
Clojure uses the ASM library to compile code to jvm bytecode.
Let's suppose I created the foo.clj and bar.clj source files.
The ns foo in foo.clj depends on the functions of bar in bar.clj.
How the compiler manages file dependencies?

Islon

-- 
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: ClojureDocs.org

2010-07-16 Thread Islon Scherer
Hi.

Does clojuredocs expose any external API (json, xml... rest,
webservices, etc) so I can access the docs from my code?

Islon

On Jul 13, 11:40 pm, j-g-faustus johannes.fries...@gmail.com wrote:
 On Jul 13, 8:37 pm, Paul Moore p.f.mo...@gmail.com wrote:

  Can I suggest omitting the Table of contents sidebar when printing?
  I've not tried printing the document to see how it looks, but removing
  the sidebar would be an essential starting point...

 Why would anyone want to print it?

 I occasionally print longer texts like specifications, but for
 reference material like Javadoc,ClojureDocs, the Ruby cheat sheet and
 this page, I think HTML is a far superior format due to links and
 browser search.
 And 40+ loose single sheets is a rather cumbersome package unless you
 have access to a book binder.

 But if at least two people feel that they would really like to print
 it out, I can skip the TOC on print.

 (Making it look _nice_ on paper is a whole different ballgame, then
 I'd have to look into pagination and page layouts, perhaps by
 converting to DocBook or LaTex. That's outside the scope of what I
 intended to do.)

 On Jul 13, 10:04 pm, Meikel Brandmeyer m...@kotka.de wrote:

  Some comments after quickly skimming through:
  ...
  PS: I'm apologise if some this seems to be nit-picking.

 Not at all, I'm still learning the language and happy to get the
 details clarified.

 The second form of condp and the #_ were omitted simply because I
 didn't know about them, thanks for the heads-up.

 For quoted lists, I take your point.
 For the sequence operations examples it was somewhat deliberate, in
 that a sequence is a very different datatype from a vector but pretty
 much the same as a list.
 I had a bug in some code that conj'ed elements onto a vector, but for
 some reason it would switch direction in the middle and start adding
 elements at the opposite end. It took me a while to figure out that it
 was because concat'ing two vectors doesn't return a vector.
 So I wanted to emphasize that using a sequence op on anything other
 than a list is also a conversion from one datatype to another.
 But I'll take another look, there may be better ways.

 Thanks for your comments, much appreciated. I'll include them with the
 next update.

 Sincerely,
 jf

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

2010-05-24 Thread islon
I missed a date/time API in clojure so I made one myself.
Is it possible to put it in clojure.contrib?
Sugestions, critics and improvements are welcome.

- http://www.copypastecode.com/29707/

Islon

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

2010-05-24 Thread Islon Scherer
Thanks for the link.
I wasn't aware of this library.

Islon

On May 24, 3:10 pm, David Nolen dnolen.li...@gmail.com wrote:
 On Mon, May 24, 2010 at 1:53 PM, islon islonsche...@gmail.com wrote:
  I missed a date/time API in clojure so I made one myself.
  Is it possible to put it in clojure.contrib?
  Sugestions, critics and improvements are welcome.

  -http://www.copypastecode.com/29707/

  Islon

 Have you looked at clj-time?http://github.com/clj-sys/clj-time

 David

 --
 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 
 athttp://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: Simlpe style question

2010-05-19 Thread islon
You can write this function in clojure in the same style:

(defn move2ascii [move]
  (let [f1 (/ move 100)
f2 (mod move 100)
row1 (int (inc (/ f1 8)))
row2 (int (inc (/ f2 8)))
col1 (char (+ (mod f1 8) 97))
col2 (char (+ (mod f2 8) 97))]
(str col1 row1 col2 row2)))

I don't think this is less idiomatic.
Just my 2¢.

Islon

On May 19, 8:56 am, edlich edl...@gmail.com wrote:
 Dear Community,

 I have one question about readability. As I am not yet deep into
 Clojure I can only post scala but I am sure you will get my point.

 Recently I wrote the following dump function in Scala:

  // convert 1228 to e2e4
   def move2ascii(move: Int): String = { // Clojure Style
     (((move / 100) % 8 + 97).toChar).toString + ((move / 100) / 8 +
 1).toString +
             (((move % 100) % 8 + 97).toChar).toString + ((move %
 100) / 8 + 1).toString
   }

 but I could as well have written it like this in an imprative style:
 (both are equal)

 def move2ascii(move: Int): String = {    // Scala Style
     val f1 = move / 100
     val f2 = move % 100
     val row1 = f1 / 8 + 1 // 2 von e2
     val row2 = f2 / 8 + 1 // 4 von e4
     val col1 = (f1 % 8 + 97).toChar // 5 = e von e2
     val col2 = (f2 % 8 + 97).toChar // 5 = e von e4
     col1.toString + row1.toString + col2.toString + row2.toString
   }

 I am sure if you write the first function in Clojure it would look
 nearly the same.

 My point and my question is:

 Isn't the second function easier to read? I know there had been a lot
 of threads about readability
 in clojure but I am not yet convinced.
 In the second version the brain can rely on some steps inbetween which
 make it more readable
 for me. Or should the first function be split up into several more
 functions to become more readable?

 I would be happy if you convince me to give Clojure a better chance.

 Thanks in advance
 Stefan Edlich

 P.S.: It's nice to see the upcoming Clojure book in Manning!

 --
 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 
 athttp://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: setting vars with macro

2010-05-17 Thread islon
Thanks for the answers.
I realized the macro wasn't a good idea and I will keep using atoms to
manage state, just found the reset! function =)

Islon

On May 17, 10:28 am, Michael Gardner gardne...@gmail.com wrote:
 On May 15, 2010, at 4:56 PM, islon wrote:

  I'm working in a simple single-thread console-based rpg game in
  clojure (a port from my own scala version)
  and didn't want to use any concurrency structure because the game is
  single threaded.
  I was thinking about a macro like

  (defmacro set!! [s val]
   `(def ~s ~val))

  so I can set my game state without using transactions, agents, etc.
  Any comments about it?

 I wrote a Pong clone in Clojure just to stretch my mind a bit. Here's what I 
 do:

 The entire game world is a single struct-map (may become a record at some 
 point), stored in a global ref. When my world-update timer fires, I deref the 
 world and then pass it to my world-updater functions. These updaters return 
 the new world state, which I then set via ref-set.

 This is almost as simple as the usual global vars approach, and allowed me to 
 trivially split the world-drawing code into another thread that runs on a 
 different schedule. It also permits stuff like printing out or saving the 
 entire world state very easily.

 Actually, were it not for Swing, I wouldn't even be using mutable structures 
 at all-- I'd be passing the world state from update to update using 
 tail-recursion.

 You might also be interested in these links:

 http://nakkaya.com/2009/12/19/cloning-pong-part-1/(I originally based my Pong 
 game on this 
 code)http://jng.imagine27.com/articles/2009-09-12-122605_pong_in_clojure.html(cloning
  Pong is apparently pretty 
 popular!)http://briancarper.net/blog/making-an-rpg-in-clojure-part-one-of-many(site
  down at the moment)http://prog21.dadgum.com/23.html(not Clojure, but 
 interesting for functional games in general)

 --
 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 
 athttp://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


setting vars with macro

2010-05-15 Thread islon
I'm working in a simple single-thread console-based rpg game in
clojure (a port from my own scala version)
and didn't want to use any concurrency structure because the game is
single threaded.
I was thinking about a macro like

(defmacro set!! [s val]
  `(def ~s ~val))

so I can set my game state without using transactions, agents, etc.
Any comments about it?

Islon

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

2008-11-21 Thread islon

I added the project in google code (github kept complaining about my
public key)
http://code.google.com/p/randomrpg/

I reduced the LOC to ~900.
I'll try once more to port it to clojure (thanks for the macro Adam),
but don't know when i'll be done.

Regards.
Islon

On Nov 21, 4:27 pm, Adam Jones [EMAIL PROTECTED] wrote:
 On Nov 20, 12:23 pm, islon [EMAIL PROTECTED] wrote:



  I'm porting my single thread simple mud-like rpg game from scala to
  clojure and one thing that is annoying me is the code needed to change
  some var.
  In scala I do things like that:

  val player = new Player(...)

  player.str += 1

  in clojure I have to do (player is a struct and its attributes are
  refs):

  (def player (Player ...))

  (dosync (ref-set player (assoc player :str (inc (:str player)

  In scala when I want mutability I just define the variable with var
  instead of val, just one letter, simple and elegant.
  It's a game, it's full of states and mutability, the game is single
  thread, I don't need transactions. Am I missing something?

 If this is really that big of a deal, you could always go the macro
 route. I'm not experienced enough to say if this is a long-term good
 decision, but here's a first pass, don't even have Clojure available
 to try it, attempt at wrapping up Chouser's suggestion (I think :=
 would be better here, but that clashes with keyword definition):

 (defmacro |= [target attr fun]
   Updates 'attr' of 'target' by passing the current value to 'fun'
 and commuting the result, all inside of a transaction
   `(dosync
     (commute ~target update-in [~attr] ~fun)))

 With usage:

 (|= player :str inc)

 That look a little better?

 -Adam
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: mutability

2008-11-20 Thread islon

Thanks Chouser.

Just to clarify some points:
I'm not saying scala ir better than clojure or clojure is bad or
immutability is a bad thing, and I know that a true game is
multithread (I'm a game programmer).
Clojure forces you to program in a thread safe way and it's a good
thing when you are doing multithread, but if you are a 100% sure that
your program is singlethreaded and will never
be multithread it's annoying all the ceremony to set a variable.
I don't think scala ir error prone to threading errors because the use
of vals is recommended, I only use vars when strictly needed, but that
is just my opinion.
I miss some easy way to do mutability and object orientation, but
otherwise clojure is great =)

Islon

On 20 nov, 17:38, Chouser [EMAIL PROTECTED] wrote:
 On Thu, Nov 20, 2008 at 3:23 PM, islon [EMAIL PROTECTED] wrote:

  in clojure I have to do (player is a struct and its attributes are
  refs):

  (def player (Player ...))

  (dosync (ref-set player (assoc player :str (inc (:str player)

 Assuming you meant:
 (def player (ref {:str 55}))
 (dosync (ref-set player (assoc @player :str (inc (:str @player)

 This could be written:
 (dosync (commute player update-in [:str] inc))

 This is somewhat shorter, but also handles more deeply-nested structures 
 easily.

  In scala when I want mutability I just define the variable with var
  instead of val, just one letter, simple and elegant.

 Simple, perhaps, but very much prone to the kind of threading issues
 that Clojure is designed to solve.  You may say today that the game is
 single-threaded, but if you ever change your mind Clojure will have
 helped you structure your code well already -- in Java or Scala you'll
 be in for some trouble.

 Work to reduce how often you modify the state, using more functional
 style until you have exactly the player object you want, and then do a
 single commute or alter.  You should find you don't need to alter
 state in as many places as you would in other languages, and when you
 do it's easier to do it in a thread-safe way.

 --Chouser
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: mutability

2008-11-20 Thread islon

Thanks for the ideas =)
I'll use agents to represent state (I don't know how I forgot it,
thanks Harrison), they are a lot more concise than refs and make a lot
more sense in my context.
Only one problem:

user= (def player (agent {:str 2 :dex 3}))
#=(var user/player)
user= @player
{:str 2, :dex 3}
user= (send (:str player) + 1)
java.lang.NullPointerException (NO_SOURCE_FILE:0)
...
Caused by: java.lang.NullPointerException
at clojure.send__547.doInvoke(boot.clj:1044)
at clojure.lang.RestFn.invoke(RestFn.java:445)
at user.eval__2681.invoke(Unknown Source)
at clojure.lang.Compiler.eval(Compiler.java:4106)
... 10 more

Ideas?

Regards.
Islon

On Nov 20, 9:24 pm, Timothy Pratley [EMAIL PROTECTED] wrote:
 Given that is the correct way to mutate state, why do we need so much
 explicit syntax?
 user= (defn += [a b c] (dosync (commute a update-in [b] #(+ c %1

 user= (+= player :str 1)
 {:str 56}
 ; are you a giant?

 Ok so if I did something like this:
 (+= player :int 5)
 (+= player :hpmax 10)
 in one thread, and on another thread did:
 (myset player :int 10)
 (myset player :hpmax 88)

 The operations might be interleaved whereas it might be desirable to
 do the 2 update actions in one transaction to prevent interleaving.
 Now this is really up to the programmer as to what is desired, however
 a group update is pretty trivial also:
 (myset player :int 10 :hpmax 88)

 Maybe there is the case where something more complex happens which I
 can't imagine and you would still need dosync... but it seems to me
 that the majority of occurrences could be hidden away by simple
 mutation functions, and these could be written much more generically
 than the one above.
 Is there an inherent problem with this approach?

 Regards,
 Tim.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: mutability

2008-11-20 Thread islon

I gave up, the resulting code would be a lot more complex than the
scala version.
But thanks for your advices.

If anyone wants to port it I can send the source code, it's ~1000
lines total.

Islon

On Nov 20, 11:38 pm, harrison clarke [EMAIL PROTECTED] wrote:
 i was thinking that each stat would be an agent.
 whatever boats your float, i guess. i'm probably not the person to go
 to about idiomatic code. :V

 user (let [player {:str (agent 5)
               :dex (agent 5)}
       str (:str player)
       dex (:dex player)]
   (println @str @dex)
   (send str + 1)
   (send dex * 2)
   (println @str @dex)
   (await str dex)
   (println @str @dex))
 5 5
 5 5
 6 10
 nil
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



clojure slime

2008-11-18 Thread islon

I checkouted the last clojure from svn, swank-clojure and clojure-mode
too.
When I start slime it give me the following errors:

Clojure
user= (add-classpath file:home/islon/opt/swank-clojure/)
nil
user=
(require (quote swank))
java.lang.Exception: No such var: swank.util/gen-and-load-class
(core.clj:39)
user=
(swank/ignore-protocol-version 2008-11-02)
java.lang.Exception: No such var: swank/ignore-protocol-version
(NO_SOURCE_FILE:5)
user=
(swank/start-server /tmp/slime.22694 :encoding iso-latin-1-unix)
java.lang.Exception: No such var: swank/start-server (NO_SOURCE_FILE:
7)
user=

It worked until I update clojure from svn.
Any ideas?

Regards.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: strings

2008-11-18 Thread islon

(defn string-reverse [s]
  (reduce #(str %1   %2) (reverse (seq (. s (split  ))

You're probably looking for something like this =)

On Nov 18, 9:00 pm, joejoe [EMAIL PROTECTED] wrote:
 hello all,
 so I'm not only new to this group but I am new to Clojure.  I may be
 going about this all wrong but here's what I got.  I want to simply
 take a string and reverse it, ex: I am cold would become cold am
 I (haha I just realized that's probably how yoda would say it).  So
 for now I am hard coding my string, so myString =I am cold.

 How I am thinking of doing this is as follows:

 (loop [i 0]
 (when ( i (count myString))
 //missing code
 //
 //
 (recur (inc i

 so this probably isn't a hard thing to do but like I said I am new to
 this all.  I basically need to figure out a way to print each element
 of myString one at a time, this would allow me to figure out how to
 reverse it.

 so to my simple question, is it possible it print each element of a
 string independently?

 I know about (first myString), which will give me I printed out three
 times.  So it seems there has to be a way and I just can't seem to
 figure it out.

 thanks for any input!

 -joejoe
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: strings

2008-11-18 Thread islon

It doesn't work:
(apply str (reverse i am cold))
dloc ma i

The correct output is cold am i. You must reverse words not letters.

On Nov 18, 11:33 pm, Kevin Downey [EMAIL PROTECTED] wrote:
 (apply str (reverse I am cold))

 shorter and it does the same thing. no need to take out the spaces and
 put them back in

 On Tue, Nov 18, 2008 at 5:21 PM, Mark Volkmann



 [EMAIL PROTECTED] wrote:

  Here's another solution that came from help on the chat. Thanks Chouser!

  (apply str (interpose   (reverse (.split I am cold  

  On Tue, Nov 18, 2008 at 7:15 PM, islon [EMAIL PROTECTED] wrote:

  (defn string-reverse [s]
   (reduce #(str %1   %2) (reverse (seq (. s (split  ))

  You're probably looking for something like this =)

  On Nov 18, 9:00 pm, joejoe [EMAIL PROTECTED] wrote:
  hello all,
  so I'm not only new to this group but I am new to Clojure.  I may be
  going about this all wrong but here's what I got.  I want to simply
  take a string and reverse it, ex: I am cold would become cold am
  I (haha I just realized that's probably how yoda would say it).  So
  for now I am hard coding my string, so myString =I am cold.

  How I am thinking of doing this is as follows:

  (loop [i 0]
  (when ( i (count myString))
  //missing code
  //
  //
  (recur (inc i

  so this probably isn't a hard thing to do but like I said I am new to
  this all.  I basically need to figure out a way to print each element
  of myString one at a time, this would allow me to figure out how to
  reverse it.

  so to my simple question, is it possible it print each element of a
  string independently?

  I know about (first myString), which will give me I printed out three
  times.  So it seems there has to be a way and I just can't seem to
  figure it out.

  thanks for any input!

  -joejoe

  --
  R. Mark Volkmann
  Object Computing, Inc.

 --
 The Mafia way is that we pursue larger goals under the guise of
 personal relationships.
     Fisheye
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure slime

2008-11-18 Thread islon

I'll not use slime right now (thanks Bill).
swank-clojure will be fixed anytime soon?

On Nov 18, 11:15 pm, Stephen C. Gilardi [EMAIL PROTECTED] wrote:
 SVN version 1110 of Clojure made a breaking change to a feature that  
 swank-clojure is using. For now, I recommend moving back one rev by  
 using:

 svn up -r 1109

 from within your checkout of clojure/trunk.

 In the past, Jeff has updated swank-clojure very quickly on those rare  
 occasions where Clojure changes enough to break it. Stay tuned.

 --Steve

 On Nov 18, 2008, at 8:01 PM, islon wrote:



  I checkouted the last clojure from svn, swank-clojure and clojure-mode
  too.
  When I start slime it give me the following errors:

  Clojure
  user= (add-classpath file:home/islon/opt/swank-clojure/)
  nil
  user=
  (require (quote swank))
  java.lang.Exception: No such var: swank.util/gen-and-load-class
  (core.clj:39)
  user=
  (swank/ignore-protocol-version 2008-11-02)
  java.lang.Exception: No such var: swank/ignore-protocol-version
  (NO_SOURCE_FILE:5)
  user=
  (swank/start-server /tmp/slime.22694 :encoding iso-latin-1-unix)
  java.lang.Exception: No such var: swank/start-server (NO_SOURCE_FILE:
  7)
  user=

  It worked until I update clojure from svn.
  Any ideas?

  Regards.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Just Wondering: Tag metadata

2008-11-14 Thread islon

There's no way to check types at compile time?

(defn len2 [#^String x]
  (. x (length)))

(defn wrong [] (len2 10))

Would be good if you could find such errors at compile time.
Optional static typing =)

Regards.
Islon

On 12 nov, 21:43, Rich Hickey [EMAIL PROTECTED] wrote:
 On Nov 12, 7:21 pm, samppi [EMAIL PROTECTED] wrote:

  Ah, yes. I meant, what are these hints? What does the compiler change?
  Is it some sort of informal type enforcement or something?

 The hints are described here:

 http://clojure.org/java_interop#typehints

 It is strictly a performance optimization so calls to Java can avoid
 reflection. There is no compile-time enforcement.

 Rich
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



primitive meta data

2008-10-15 Thread Islon
Hi.

I've made a dumb (very dumb) performance comparison function just to play
with the language.
I wanted to mark some symbols with a float primitive type but the compiler
complained so I had to annotate it with the Float class.
Here is the function:

(defn dumb-test []
  (let [#^Float f2 567.09723]
(loop [#^Float f 1.8, i 1000]
  (if (zero? i)
f
(recur (/ f f2) (dec i))

And the test:

(loop [i 50]
  (time (dumb-test))
  (if (zero? i)
i
(recur (dec i

There's a way to put a float primitive type in the metadata to prevent the
Float - float unboxing?
Feel free to point some mistakes I probably made, I've just started learn
clojure.

The clojure version took an average: Elapsed time: 217.833342 msecs in my
machine.

The java version (below) took average 23 msecs:

private static float dumbTest() {
float f = 1.8f;
float f2 = 567.09723f;
for(int i = 0; i  1000; i++) {
f /= f2;
}
return f;
}

Regards.
Islon

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: primitive meta data

2008-10-15 Thread Islon
Thanks for the advices.
The unchecked version run as fast as java.
Before I go solve some interesting problem I have to learn the language ;)
Thanks anyway.

On Wed, Oct 15, 2008 at 12:04 PM, Chouser [EMAIL PROTECTED] wrote:


 On Wed, Oct 15, 2008 at 7:08 AM, Parth Malwankar
 [EMAIL PROTECTED] wrote:
 
  On Oct 15, 8:34 am, Islon [EMAIL PROTECTED] wrote:
 
  (defn dumb-test []
(let [#^Float f2 567.09723]
  (loop [#^Float f 1.8, i 1000]
(if (zero? i)
  f
  (recur (/ f f2) (dec i))

 The type hints aren't really helping there, I think.  #^Float might
 help if you were calling a Java function and wanted to avoid the
 runtime reflection lookup cost, but you're only calling Clojure
 functions so it doesn't help.

 On my machine, about 180 msecs

 To get unboxed primitives, you have to do more like what Parth did:

  (defn dumb-test []
   (let [f2 (float 567.09723)]
 (loop [f (float 1.2), i (long 1000)]
   (if (zero? i)
 f
 (recur (/ f f2) (dec i))

 On my machine that's 48 msecs.

 But we can do a bit better, just by using unchecked-dec:

 (defn dumb-test []
  (let [f2 (float 567.09723)]
   (loop [f (float 1.2), i (long 1000)]
 (if (zero? i)
   f
(recur (/ f f2) (unchecked-dec i))

 That's 24 msecs for me.

 But I don't know how useful these kinds of micro-benchmarks really
 are.  Clojure's fast enough so let's go solve some interesting
 problems...

 --Chouser

 


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: remainder function

2008-10-15 Thread Islon
Same problem for me.
I didn't know there's a find-doc function, thanks!

Regards

On Wed, Oct 15, 2008 at 6:44 PM, Achim Passen [EMAIL PROTECTED]wrote:


 Hi,

 Am 15.10.2008 um 23:35 schrieb Islon:

  Is there a remainder (rest of the division) function in closure? (as
  java '%' operator).
  I browse the docs but couldn't find one.

 clojure/rem
 ([num div])
   rem[ainder] of dividing numerator by denominator.

 I ran into the same problem some time ago - find-doc/searching for
 remainder doesn't work here, for obvious reasons. Maybe it's a good
 idea to change the doc string?

 Kind regards,
 achim

 


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---