Re: Russ olsen's Clojure Book

2011-06-29 Thread Sean Corfield
On Wed, Jun 29, 2011 at 9:07 PM, Vivek Khurana wrote: >  Many of the design patterns as presented by Gang of Four and Martin > Fowler are strictly OO based are suitable for only for OO based > languages. I don't agree - I think many of those patterns can be applied in a non-OO world but the imple

Re: Russ olsen's Clojure Book

2011-06-29 Thread flebber
Yes I did mean design patterns in ruby, by Russ Olsen. > >  Many of the design patterns as presented by Gang of Four and Martin > Fowler are strictly OO based are suitable for only for OO based > languages. > I think essentially that's what would make it such an interesting read. A total paradigm

RE: Translating Java code with nested for loops

2011-06-29 Thread Bhinderwala, Shoeb
Hi Alan I really liked the way you kept refactoring the original solution by Huahai to make it more and more logical and elegant. I verified that each refactored function produced the correct results. Thanks for sharing your valuable thoughts and techniques. Shoeb -Original Message- F

Re: Translating Java code with nested for loops

2011-06-29 Thread Huahai Yang
Missed that one. Yeah, that's much nicer. -huahai On Jun 29, 6:39 pm, Alan Malloy wrote: > (* daily (reduce * 1 coll)) > ;; is exactly equal to > (reduce * daily coll) > > My point is you can start with daily instead of with 1, and thus not > have to special-case it in at the end. > > On Jun 29,

Re: Russ olsen's Clojure Book

2011-06-29 Thread Vivek Khurana
On Thu, Jun 30, 2011 at 8:39 AM, flebber wrote: > > Just wanted to put a shout out to Russ Olsen to see what would be > needed to get a Russ Olsen book on clojure to happen. I am reading > design principles in Ruby and its a great read, I feel I am learning > much moe than just Ruby which is why I

Re: bootclasspath

2011-06-29 Thread Kevin Downey
I have attached a patch to the jira issue http://dev.clojure.org/jira/browse/CLJ-673 it checks for a null classloader before calling methods, if the classloader is null it uses ClassLoader.getSystemResource or ClassLoader.getSystemResourceAsStream On Sat, Nov 6, 2010 at 2:04 PM, Phil Hagelberg

Russ olsen's Clojure Book

2011-06-29 Thread flebber
Just wanted to put a shout out to Russ Olsen to see what would be needed to get a Russ Olsen book on clojure to happen. I am reading design principles in Ruby and its a great read, I feel I am learning much moe than just Ruby which is why I am reading it. I woould absolutely love to read how Russ

Continuations or monads or something

2011-06-29 Thread Dave Ray
Hi, Yesterday I read this article [1] on asynchronous UI workflows in F#. Basically, taking a sequential set of steps in a UI that would normally be spread across a bunch of event handlers, and making it look like sequential code in one place. So tonight I took a stab at implementing something lik

Re: Other way to express (((m2) 2) 1)?

2011-06-29 Thread Scott Jaderholm
Here's another, perhaps very controversial, solution: (in m.2.2.1) ;; in (defn flexible-get ([map key] (or (let [k (read-string key)] (and (number? k) (get map k))) (get map (keyword key)) (get map (name key ([map key & more] (apply f

Re: Other way to express (((m2) 2) 1)?

2011-06-29 Thread Scott Jaderholm
(defmacro ->f "like -> but f is threaded at pos 0 instead of 1" ([f] f) ([f x] `(~f ~x)) ([f x & more] `(->f (~f ~x) ~@more))) (->f m 2 2 1) Scott On Wed, Jun 29, 2011 at 7:00 PM, Antonio Recio wrote: > Is there other way to express (((m2) 2) 1)? > (def m [1 2 [21 22 [221 222 22

Re: Translating Java code with nested for loops

2011-06-29 Thread Alan Malloy
(* daily (reduce * 1 coll)) ;; is exactly equal to (reduce * daily coll) My point is you can start with daily instead of with 1, and thus not have to special-case it in at the end. On Jun 29, 8:22 am, Huahai Yang wrote: > The multiplication outside the reduce is required because it is part > of

Re: Other way to express (((m2) 2) 1)?

2011-06-29 Thread David Nolen
On Wed, Jun 29, 2011 at 8:54 PM, Dmitry Gutov wrote: > You can use 'reduce': > > (reduce nth m [2 2 1]) > ;; or, for the general case > (reduce #(%1 %2) m [2 2 1]) or (reduce get m [2 2 1]) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Re: Other way to express (((m2) 2) 1)?

2011-06-29 Thread Dmitry Gutov
You can use 'reduce': (reduce nth m [2 2 1]) ;; or, for the general case (reduce #(%1 %2) m [2 2 1]) On Jun 30, 3:20 am, Antonio Recio wrote: > (get-in m [2 2 1]) is great! Which are the others ones? Is there something > like (-> m [2 2 1])? -- You received this message because you are subscri

Re: Complement to clojure survey

2011-06-29 Thread Milton Silva
At this point there are 69 responses, I think they are enough to draw some conclusions but I'll keep the survey open till later today(to see if we can get around 100 responses). As soon I close it, the results will be available for everyone. On Jun 23, 9:22 pm, Milton Silva wrote: > As suggested

Re: Other way to express (((m2) 2) 1)?

2011-06-29 Thread Tom Hicks
Sortof, but not as concisely, since the op is repeated each time: (-> m (nth 2) (nth 2) (nth 1)) -tom On Jun 29, 4:20 pm, Antonio Recio wrote: > (get-in m [2 2 1]) is great! Which are the others ones? Is there something > like (-> m [2 2 1])? -- You received this message because you are su

Re: Other way to express (((m2) 2) 1)?

2011-06-29 Thread Antonio Recio
(get-in m [2 2 1]) is great! Which are the others ones? Is there something like (-> m [2 2 1])? -- 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 moderat

Re: Guide to Programming in Clojure for Beginners

2011-06-29 Thread Sean Corfield
On Tue, Jun 28, 2011 at 8:21 PM, Tim Robinson wrote: > http://blackstag.com/blog.posting?id=5 > > I have now have a newly found appreciation for how much effort this > kind of stuff can be :) Really nice set of posts - thank you for your effort!! -- Sean A Corfield -- (904) 302-SEAN An Architect

Re: Other way to express (((m2) 2) 1)?

2011-06-29 Thread David Nolen
On Wed, Jun 29, 2011 at 7:00 PM, Antonio Recio wrote: > (def m [1 2 [21 22 [221 222 223] 23] 3]) > (((m 2) 2) 1) > One my favorites. (get-in m [2 2 1]) David -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clo

Other way to express (((m2) 2) 1)?

2011-06-29 Thread Antonio Recio
Is there other way to express (((m2) 2) 1)? (def m [1 2 [21 22 [221 222 223] 23] 3]) (((m 2) 2) 1) ;-> 222 -- 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

Re: Hygenic approach for using Java2D from Clojure?

2011-06-29 Thread Mikhail Kryshen
Here are some ideas I used in Indyvon (https://bitbucket.org/kryshen/ indyvon). * Methods that modify graphics context (java.awt.Graphics2D instance) are wrapped in with- macros, e.g. with-color sets the current color to the specified value, executes body in try block, and resets the color to the

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 wrot

Re: Is there anything other than gen-class I can use if deftype comes just slightly short?

2011-06-29 Thread Chas Emerick
There's absolutely no shame in, where appropriate, writing a dash of Java if your Java interop requirements are simultaneously specific and unshakable. You could write a Java class with a single static factory method that returns an instance of the deftype class and that does whatever initializ

Re: date-clj clojure date/time library

2011-06-29 Thread Laurent PETIT
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 wit

Re: date-clj clojure date/time library

2011-06-29 Thread Laurent PETIT
java.util.Date instances aren't immutable. 2011/6/29 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 :nov

Re: Tutorial about web development with Clojure

2011-06-29 Thread Sergey Didenko
Nice to see so documented example! A few remarks: 1) IMHO sandbar's approach to authorization is better that this ad-hoc one: it places auth data just in the routes instead of controllers, see https://github.com/brentonashworth/sandbar/wiki/Authentication-and-Authorization 2) It would be nice to

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) -> # (-> (today) (set-date :month :december :year 1900)) -> # (f

Is there anything other than gen-class I can use if deftype comes just slightly short?

2011-06-29 Thread Alex Rozenshteyn
I asked on IRC, I asked on SO[1] and I'll ask here as well, because this seems like a question to which the answer shouldn't be "Just use gen-class". The summary of my predicament: I need a Java class that implements an interface, has a nullary constructor that performs initialization, and has som

RE: Translating Java code with nested for loops

2011-06-29 Thread Bhinderwala, Shoeb
Thanks to all for the excellent and quick responses. David - you are right the variable should be called product not sum. This is just some poorly written Java code that I am translating to Clojure. Justin - thanks for the idea on how to visualize such algorithms and the picture you shared. -

Re: Idiomatic way to reference a bundled data file from Clojure source?

2011-06-29 Thread Shantanu Kumar
The idiomatic way may be to include the file(s) in the classpath and there is already a `resource` function in clojure.java.io that can load it from the classpath: $ lein new foo $ cd foo $ mkdir resources $ cat>resources/test.txt hello world foo bar ^D $ # edit src/foo/core.clj as follows (ns foo

Re: Where's old contrib string, str-utils and str-utils2

2011-06-29 Thread B Smith-Mannschott
On Wed, Jun 29, 2011 at 17:45, Timothy Washington wrote: > That's what I thought too, but I didn't see it in the source. I also fired > up the repl and tried some of the functions from str-utils2, and they > weren't there... > $ lein repl > user=> (require 'clojure.string) > nil > user=> (clojure.

Re: Where's old contrib string, str-utils and str-utils2

2011-06-29 Thread Timothy Washington
That's what I thought too, but I didn't see it in the source. I also fired up the repl and tried some of the functions from str-utils2, and they weren't there... *$ lein repl * *user=> (require 'clojure.string) * *nil * *us

Aw: Where's old contrib string, str-utils and str-utils2

2011-06-29 Thread Meikel Brandmeyer
Hi, I think they moved to clojure.string. Sincerely Meikel -- 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 fi

Re: Translating Java code with nested for loops

2011-06-29 Thread Huahai Yang
The multiplication outside the reduce is required because it is part of the original logic: "contrib[i] = sum * dailyValues[i];". Using the drop function is a very good call though. -huahai On Jun 29, 12:53 am, Alan Malloy wrote: > If you're already doing a bunch of multiplication in the reduce,

Where's old contrib string, str-utils and str-utils2

2011-06-29 Thread Timothy Washington
Hi there, I'm starting to dig into 1.3 and the associated libraries. I know the monolithic contrib library is no longer supported. But in the old contrib library, there were the *string*, *str-utils* and *str-utils2* libs. I don't see those or their corresponding functions in the new https://gith

Re: Tutorial about web development with Clojure

2011-06-29 Thread Tarantoga
Dmitry Gutov has improved the tutorial. The code looks much better now! -- 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 wi

Presentation of the Lacij graph visualization library

2011-06-29 Thread Pierre Allix
Hello, I have uploaded a short presentation of the Lacij graph visualization library. It can be found here: https://docs.google.com/present/view?id=dsjwfrk_1js9ptkcd Lacij is on GitHub: https://github.com/pallix/lacij -- You received this message because you are subscribed to the Google Group

Re: Translating Java code with nested for loops

2011-06-29 Thread Alan Malloy
On Jun 29, 12:55 am, Ken Wesson wrote: > On Wed, Jun 29, 2011 at 3:53 AM, Alan Malloy wrote: > > This layout makes it fairly clear that the first element of total- > > values is never being used, but it would be nice if we could say so > > explicitly. So finally, we can wrap the whole thing in a

Re: Guide to Programming in Clojure for Beginners

2011-06-29 Thread Shantanu Kumar
This is very nice indeed. Thanks for putting it up. Regards, Shantanu On Jun 29, 3:21 am, Tim Robinson wrote: > I'm fairly new to Programming, Clojure and Blogging, but I did manage > to write a few posts about Clojure in my spare time. > > http://blackstag.com/blog.posting?id=5 > > I have now h

Re: Translating Java code with nested for loops

2011-06-29 Thread Ken Wesson
On Wed, Jun 29, 2011 at 3:53 AM, Alan Malloy wrote: > This layout makes it fairly clear that the first element of total- > values is never being used, but it would be nice if we could say so > explicitly. So finally, we can wrap the whole thing in a let: > > (defn calc [total-values daily-values]

Re: Translating Java code with nested for loops

2011-06-29 Thread Alan Malloy
If you're already doing a bunch of multiplication in the reduce, you don't need to do it outside as well, do you? And because reduce doesn't care about laziness, you can use drop instead of nthnext (which I think is clearer in almost all cases). (defn calc [total-values daily-values] (map-index