Re: Russ olsen's Clojure Book

2011-06-30 Thread Stefan Kamphausen
Hi, did you notice that Fogus and Houser do talk about Design Patterns at the end of their book? Cheers, Stefan -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new m

Re: Russ olsen's Clojure Book

2011-06-30 Thread Vivek Khurana
On Thu, Jun 30, 2011 at 12:10 PM, Sean Corfield wrote: > 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 ma

Re: Russ olsen's Clojure Book

2011-06-30 Thread Florian Over
I also recommend to read the last chapter of the book "Thinking in Clojure". They have a good overview of equivalences of OO design pattern. (If needed) If you want to "Think clojure" (maybe Think Lisp) this is the book for you! Best regards Florian Over 2011/6/30 Vivek Khurana > On Thu, Jun 3

Aw: Continuations or monads or something

2011-06-30 Thread Meikel Brandmeyer
Hi again, await-event is not thread-safe. (defn await-event [target event] (let [evt (promise) remove-fn (promise) handler (fn [e] (@remove-fn) (deliver evt e))] (deliver remove-fn (listen target event handler)) @evt)) remove-fn should also be a promise. Other

Re: ClassCastException on 'clojure.data.json/print-json'

2011-06-30 Thread Stuart Sierra
clojure.core/*out* is usually a PrintWriter, but its docstring only specifies that it's a Writer. So it's a bug for data.json to assume PrintWriter. I'll fix it. -Stuart Sierra clojure.com -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

Re: Any ways to prevent protocol functions from being hardcoded in?

2011-06-30 Thread Stuart Sierra
Yeah, inline method definitions in a deftype/defrecord are compiled right into the generated class; no Vars involved. That's why they're fast. Recently the received wisdom has been: protocols are a low-level implementation detail. Actual APIs should be built with normal functions that call the

Re: ClassCastException on 'clojure.data.json/print-json'

2011-06-30 Thread Timothy Washington
I already made a quick fix and put in a github pull request. You can do whichever is easier. Tim Washington twash...@gmail.com 416.843.9060 On Thu, Jun 30, 2011 at 8:52 AM, Stuart Sierra wrote: > clojure.core/*out* is usually a PrintWriter, but its docstring only > specifies that it's a Write

Re: Continuations or monads or something

2011-06-30 Thread Dave Ray
Thanks! In theory, this should only ever happen on the UI thread so it's not an issue, but better safe than sorry. Any thoughts on the overall premise or approach? Dave On Thu, Jun 30, 2011 at 8:22 AM, Meikel Brandmeyer wrote: > Hi again, > > await-event is not thread-safe. > > (defn await-even

Supplying Arguments to Function That conj's map

2011-06-30 Thread octopusgrabbus
I have a sequence (def mtr-seq ["a" 1 "b" 2 "c" 3 "d" 4]) and a function (defn map-mtr [read-map premid reading] (conj :read-map {:premid reading})) I do not understand how to select the first and second of the sequence to be put into mtr-seq. This (map-mtr [mtr-map][(first mt

Re: Supplying Arguments to Function That conj's map

2011-06-30 Thread octopusgrabbus
Fixed by doing this: (defn map-mtr [read-map premid reading] (conj read-map {premid reading})) On Jun 30, 11:11 am, octopusgrabbus wrote: > I have a sequence > > (def mtr-seq ["a" 1 "b" 2 "c" 3 "d" 4]) > > and a function > > (defn map-mtr >         [read-map premid reading] >  

How do Clojure functions update def variables

2011-06-30 Thread octopusgrabbus
Given this empty map, (def mtr-map {}) this sequence, (def mtr-seq ["a" 1 "b" 2 "c" 3 "d" 4]) this function, (defn map-mtr [read-map premid reading] (conj read-map {premid reading})) and this call (map-mtr mtr-map (first mtr-seq) (first (rest mtr-seq))) mtr-map won't update, but red

Re: How do Clojure functions update def variables

2011-06-30 Thread Mark Rathwell
Clojure data structures are immutable by default (see http://clojure.org/functional_programming). For mutability, see the following: http://clojure.org/vars http://clojure.org/atoms http://clojure.org/refs http://clojure.org/agents http://clojure.org/transients On

Re: Continuations or monads or something

2011-06-30 Thread Meikel Brandmeyer
Hi Dave, Am Donnerstag, 30. Juni 2011 17:02:48 UTC+2 schrieb daveray: > > Any thoughts on the overall premise or approach? As I wrote in the longer email, I don't particular like the ceremony imposed by the approach. This whole thing is similar to Node.js - AFAIU. My idea on the other hand in

Re: How do Clojure functions update def variables

2011-06-30 Thread octopusgrabbus
Thanks you for answering. I should rephrase the question, and I'll go look at the links you posted. I'm wondering why conj worked in the first of the function that operated on the mtr-map defined by def, and not in the version where mtr-map was passed in as the first parameter. On Jun 30, 11:48 

Re: How do Clojure functions update def variables

2011-06-30 Thread Mark Rathwell
It shouldn't. I can't duplicate what I think you are saying. Would you be able to you print the code you entered in the repl that produced these results? On Thu, Jun 30, 2011 at 12:02 PM, octopusgrabbus wrote: > Thanks you for answering. > > I should rephrase the question, and I'll go look at

Re: How do Clojure functions update def variables

2011-06-30 Thread octopusgrabbus
You're correct. They both do the same thing. Both do not update mtr- map. Clearly I need to assign a local variable in a let statement. (mtr-map passed as parameter version) (def mtr-seq ["a" 1 "b" 2 "c" 3 "d" 4]) (defn map-mtr [read-map premid reading] (conj read-map {premid re

Re: How do Clojure functions update def variables

2011-06-30 Thread Phil Hagelberg
Mark Rathwell writes: > Clojure data structures are immutable by default > (see http://clojure.org/functional_programming). > > For mutability, see the following: > > [...] > > http://clojure.org/transients It's a common misconception that transients are meant to be used for mutable data, but th

Re: How do Clojure functions update def variables

2011-06-30 Thread Mark Rathwell
True, I did not mean to imply that they should be used in situations such as this, only that they are data structures in the language that are mutable, and have situations where they may be useful. - Mark On Thu, Jun 30, 2011 at 12:17 PM, Phil Hagelberg wrote: > Mark Rathwell writes: > > > Cl

Filling let local variable from sequence

2011-06-30 Thread octopusgrabbus
Given this function (defn map-func "test map function" [] (let [mtr-seq (vector "a" 1 "b" 2 "c" 3 "d" 4) read-map () (println read-map))) I want to load read-map with the keys and values from mtr-seq. Eventually, this data is going to be from the return from pars

Re: Filling let local variable from sequence

2011-06-30 Thread Mark Rathwell
One way would be: (defn map-func "test map function" [] (let [mtr-seq (vector "a" 1 "b" 2 "c" 3 "d" 4) read-map (apply hash-map mtr-seq) (println read-map))) On Thu, Jun 30, 2011 at 1:09 PM, octopusgrabbus wrote: > > Given this function > > (defn map-func >"test m

Re: Filling let local variable from sequence

2011-06-30 Thread octopusgrabbus
Thanks. That did it. On Jun 30, 1:22 pm, Mark Rathwell wrote: > One way would be: > > (defn map-func >    "test map function" >    [] >    (let [mtr-seq (vector "a" 1 "b" 2 "c" 3 "d" 4) >          read-map (apply hash-map mtr-seq) >          (println read-map))) > > On Thu, Jun 30, 2011 at 1:09 P

Re: ANN: Hafni

2011-06-30 Thread Scott Jaderholm
In arrow.clj: What is iarr an abbreviation for? Perhaps a docstring on ||| would help, I'm having trouble understanding it. Maybe add these examples, I found them helpful ((arr inc) 1) ;; 2 ((>>> (arr inc) (arr dec)) 1) ;; 1 ((flow (arr inc) >>> (arr inc) >>> (arr inc)) 1) ;; 4 ((*** (arr in

Re: Filling let local variable from sequence

2011-06-30 Thread octopusgrabbus
If I have rows of vectors, such as the return from clojure-csv\parse- csv ["a" 1 "b" 2 "c" 3 "d" 4] ["e" 5 "f" 6 "g" 7 "h" 8] How can I break up each row? I've tried doseq in the let statement, but get an error. On Jun 30, 2:27 pm, octopusgrabbus wrote: > Thanks. That did it. > > On Jun 30, 1

Re: Filling let local variable from sequence

2011-06-30 Thread Mark Rathwell
Not sure what you mean by 'row of vectors', and 'break up each row'. On Thu, Jun 30, 2011 at 3:20 PM, octopusgrabbus wrote: > If I have rows of vectors, such as the return from clojure-csv\parse- > csv > > ["a" 1 "b" 2 "c" 3 "d" 4] > ["e" 5 "f" 6 "g" 7 "h" 8] > > How can I break up each row? > >

Re: ClassCastException on 'clojure.data.json/print-json'

2011-06-30 Thread Aaron Bedra
The process for getting code into Clojure's official libraries is the same as it is for the language. We work with patches submitted to JIRA (http://dev.clojure.org/jira) rather than github pull requests. It allows us to track things a little bit easier. We also require that all contributors

Re: Filling let local variable from sequence

2011-06-30 Thread octopusgrabbus
The dorun in this function (defn process-file "Process csv file and prints first item in every row" [file-name] (let [data (slurp file-name) rows (parse-csv data)] (dorun (map #(println (first %)) rows causes each row of vectors in rows to be processed. (doseq [a-row rows]

Re: Filling let local variable from sequence

2011-06-30 Thread Ken Wesson
On Thu, Jun 30, 2011 at 4:15 PM, octopusgrabbus wrote: > The dorun in this function > > (defn process-file >  "Process csv file and prints first item in every row" >  [file-name] >  (let [data (slurp file-name) >        rows (parse-csv data)] >    (dorun (map #(println (first %)) rows > > caus

Re: Filling let local variable from sequence

2011-06-30 Thread octopusgrabbus
Thanks for answering. I want to create a map of this output: PremiseID Reading 61016 101100 610159000 411200 610158000 133100 610157000 239400 nil nil produced by this function (defn process-file "Process csv file and prints a column in every row" [file-name] (let [data (slurp file-na

Re: Filling let local variable from sequence

2011-06-30 Thread octopusgrabbus
Thanks, Ken. Our answers crossed. I'll go try your suggestions. On Jun 30, 4:24 pm, Ken Wesson wrote: > On Thu, Jun 30, 2011 at 4:15 PM, octopusgrabbus > > > > > > > > > > wrote: > > The dorun in this function > > > (defn process-file > >  "Process csv file and prints first item in every row" >

Re: Complement to clojure survey

2011-06-30 Thread Milton Silva
Results are open(to see the graphs, go to form->show summary of responses). The contrib results aren't very meaningful but, the rest are interesting. https://spreadsheets.google.com/spreadsheet/ccc?key=0AldCQypVmS28dFFJTTZWT2lXR1N1dTJTWk5mdjZXZlE&hl=en_US On Jun 30, 2:06 am, Milton Silva wrote:

Re: Filling let local variable from sequence

2011-06-30 Thread Ken Wesson
On Thu, Jun 30, 2011 at 4:30 PM, octopusgrabbus wrote: > Thanks for answering. > > I want to create a map of this output: > > PremiseID Reading > 61016 101100 > 610159000 411200 > 610158000 133100 > 610157000 239400 > nil nil > > produced by this function > > (defn process-file >  "Process csv

Re: Complement to clojure survey

2011-06-30 Thread Phil Hagelberg
Milton Silva writes: > Results are open(to see the graphs, go to form->show summary of responses). Thanks. The Form menu seems to be disabled for anonymous viewers. -Phil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: Filling let local variable from sequence

2011-06-30 Thread octopusgrabbus
I need to clarify my previous answer. In each row of vectors I want to extract two columns and make a map of those. For example, for each premiseid, there is a reading. So for this line of data 33891715,101100,"2011-06-05 23:00:00","61016","SMITH","E & J", 80581200,43,0,75,"2011-06-06 06:00

Re: Filling let local variable from sequence

2011-06-30 Thread octopusgrabbus
Phew! Thank you. That did it. I did need to add the nil to each nth statement, but this helps. (defn process-file "Process csv file and prints a column in every row" [file-name] (let [data (slurp file-name) rows (parse-csv data) read-map (zipmap (map #(nth % 11 nil) rows) (ma

Re: Russ olsen's Clojure Book

2011-06-30 Thread Brian Marick
On Jun 29, 2011, at 10:09 PM, flebber wrote: > I woould absolutely love to read how Russ would apply these design > principles to Clojure a more functional language. If I recall right, Felleisen et al's /A Little Java, A Few Patterns/, despite using Java, uses a heavily functional style. I rem

Re: Any ways to prevent protocol functions from being hardcoded in?

2011-06-30 Thread Brian Marick
On Jun 30, 2011, at 7:54 AM, Stuart Sierra wrote: > Recently the received wisdom has been: protocols are a low-level > implementation detail. Actual APIs should be built with normal functions that > call the protocol methods. Interesting. So I'm not encouraged to think "protocols" except when

Re: Any ways to prevent protocol functions from being hardcoded in?

2011-06-30 Thread Laurent PETIT
2011/6/30 Brian Marick : > > On Jun 30, 2011, at 7:54 AM, Stuart Sierra wrote: > >> Recently the received wisdom has been: protocols are a low-level >> implementation detail. Actual APIs should be built with normal functions >> that call the protocol methods. > > > Interesting. So I'm not encoura

Re: Complement to clojure survey

2011-06-30 Thread Milton Silva
try this link https://spreadsheets.google.com/spreadsheet/gform?key=0AldCQypVmS28dFFJTTZWT2lXR1N1dTJTWk5mdjZXZlE&hl=en_US&gridId=0#chart On Jun 30, 9:49 pm, Phil Hagelberg wrote: > Milton Silva writes: > > Results are open(to see the graphs, go to form->show summary of responses). > > Thanks. T

Re: Complement to clojure survey

2011-06-30 Thread Phil Hagelberg
Milton Silva writes: > try this link > > https://spreadsheets.google.com/spreadsheet/gform?key=0AldCQypVmS28dFFJTTZWT2lXR1N1dTJTWk5mdjZXZlE&hl=en_US&gridId=0#chart Still doesn't work for unauthorized users: You need permission to access this item. You are signed in as [...], but you do

Re: Complement to clojure survey

2011-06-30 Thread Milton Silva
The graphs are now in sheet 3 and 4. I could not find a way to enable users to view the summary. On Jun 30, 11:37 pm, Phil Hagelberg wrote: > Milton Silva writes: > > try this link > > >https://spreadsheets.google.com/spreadsheet/gform?key=0AldCQypVmS28dF... > > Still doesn't work for unauthoriz

Re: Complement to clojure survey

2011-06-30 Thread Sean Corfield
Thanx Milton! Interesting results on the books. I suspect it's just a bit too early in the curve for Chas's book to score more highly (I'm very impressed with the Rough Cut so far!). Nice to see lein leading the build tools by such a margin - I'd love to see lein "endorsed" as the primary recomme

Re: Russ olsen's Clojure Book

2011-06-30 Thread Sean Corfield
On Thu, Jun 30, 2011 at 2:34 AM, Florian Over wrote: > I also recommend to read the last chapter of the book "Thinking in Clojure". Do you mean Joy of Clojure? Here's what Fogus and Chouser say: "Most if not all of the patterns listed in the book are applicable to functional programming languag

Re: Complement to clojure survey

2011-06-30 Thread Phil Hagelberg
Milton Silva writes: > The graphs are now in sheet 3 and 4. I could not find a way to enable > users to view the summary. That works; thanks! -Phil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@google

Re: Complement to clojure survey

2011-06-30 Thread Chas Emerick
Bummer, looks like I missed the survey. I think most people can guess my responses anyway. ;-) I'm actually surprised that Maven scored as high as it did, but it makes sense — as Aaron mentioned, it's a sane fallback when lein isn't "enough". I *am* surprised that enlive isn't the runaway favo

Re: Any ways to prevent protocol functions from being hardcoded in?

2011-06-30 Thread Meikel Brandmeyer
Hi, Am 01.07.2011 um 00:16 schrieb Laurent PETIT: >> On Jun 30, 2011, at 7:54 AM, Stuart Sierra wrote: >> >>> Recently the received wisdom has been: protocols are a low-level >>> implementation detail. Actual APIs should be built with normal functions >>> that call the protocol methods. > > B

Re: ClassCastException on 'clojure.data.json/print-json'

2011-06-30 Thread Timothy Washington
Ah, I see I see. I think this was a one off thing, and pretty simple - so Stuart fixing it is fine. If I come across a few more patches I'd like to submit, I'll definitely go through this process. Thanks for the information Aaron. Tim Washington twash...@gmail.com 416.843.9060 On Thu, Jun 30,

Re: Complement to clojure survey

2011-06-30 Thread Milton Silva
On Jun 30, 11:55 pm, Sean Corfield wrote: > Thanx Milton! > > Interesting results on the books. I suspect it's just a bit too early > in the curve for Chas's book to score more highly (I'm very impressed > with the Rough Cut so far!). > I know but, I also saw no reason not to include it and if

Re: Any ways to prevent protocol functions from being hardcoded in?

2011-06-30 Thread Chas Emerick
On Jun 30, 2011, at 7:38 PM, Meikel Brandmeyer wrote: > Hi, > > Am 01.07.2011 um 00:16 schrieb Laurent PETIT: > >>> On Jun 30, 2011, at 7:54 AM, Stuart Sierra wrote: >>> Recently the received wisdom has been: protocols are a low-level implementation detail. Actual APIs should be bui

Re: Complement to clojure survey

2011-06-30 Thread Milton Silva
On Jul 1, 12:26 am, Chas Emerick wrote: > Bummer, looks like I missed the survey.  I think most people can guess my > responses anyway. ;-) > Yeah, I didn't advertised it enough, this type of things is probably best done by people with "pull" (e.g. with a lot of followers on twitter), maybe n

Re: Complement to clojure survey

2011-06-30 Thread Sean Corfield
On Thu, Jun 30, 2011 at 5:37 PM, Milton Silva wrote: > I wish that book also had preview chapters like joy of clojure, that > would very probably earn it some more early buys. (that was what > happened with me in relation to joc) You can buy it in Rough Cuts and it's already had one update since

Re: Complement to clojure survey

2011-06-30 Thread Milton Silva
On Jul 1, 1:43 am, Sean Corfield wrote: > On Thu, Jun 30, 2011 at 5:37 PM, Milton Silva wrote: > > I wish that book also had preview chapters like joy of clojure, that > > would very probably earn it some more early buys. (that was what > > happened with me in relation to joc) > > You can buy it

Re: Complement to clojure survey

2011-06-30 Thread Sean Corfield
On Thu, Jun 30, 2011 at 5:48 PM, Milton Silva wrote: > Sorry, I meant that one of the things that made me buy the MEAP of > JOC were the free preview chapters. FWIW, Rough Cuts does have a preview mode that lets you read the first few pages of each section (as I recall - hard to test now I've bou

Re: Complement to clojure survey

2011-06-30 Thread Chas Emerick
On Jun 30, 2011, at 8:51 PM, Sean Corfield wrote: > On Thu, Jun 30, 2011 at 5:48 PM, Milton Silva wrote: >> Sorry, I meant that one of the things that made me buy the MEAP of >> JOC were the free preview chapters. > > FWIW, Rough Cuts does have a preview mode that lets you read the first > few

Re: Russ olsen's Clojure Book

2011-06-30 Thread flebber
@Florian < If you want to "Think clojure" (maybe Think Lisp) this is the book for you! Do you know the author I am on amazon and cannot find this book. @Brian - A Little Java, A Few Patterns Thanks looks good, think will add it to my order. Sayth -- You received this message because you are

Re: Any ways to prevent protocol functions from being hardcoded in?

2011-06-30 Thread Laurent PETIT
2011/7/1 Chas Emerick : > > On Jun 30, 2011, at 7:38 PM, Meikel Brandmeyer wrote: > >> Hi, >> >> Am 01.07.2011 um 00:16 schrieb Laurent PETIT: >> On Jun 30, 2011, at 7:54 AM, Stuart Sierra wrote: > Recently the received wisdom has been: protocols are a low-level > implementation

Re: Any ways to prevent protocol functions from being hardcoded in?

2011-06-30 Thread Meikel Brandmeyer
Hi, Am Freitag, 1. Juli 2011 02:34:01 UTC+2 schrieb Chas Emerick: > > But, you'd never do that, right? Each implementation of Vector and Map > would have their own idiosyncratic implementations of `get`, and you _want_ > (need) that bolted into the deftyped class. > > Brian was looking to be ab

Aw: Continuations or monads or something

2011-06-30 Thread Meikel Brandmeyer
Hi, BTW, did you look at the monad package in contrib? (The new one is algo.monad, I think.) Maybe you could use the continuation monad (which this basically is) for the infrastructure. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" gro