2008/9/16 Chouser <[EMAIL PROTECTED]> > > On Tue, Sep 16, 2008 at 4:49 AM, Alexander Kjeldaas > <[EMAIL PROTECTED]> wrote: > > > > 2. Clojure states that it has good support for list comprehensions. > > Maybe I'm misunderstanding list comprehensions, but I'm not completely > > happy. I want a way to have destructuring work on the sequence, not > > on the individual element. In CL you have (loop for i in '(1 2 3) ...) > > as well as (loop for i on '(1 2 3) ...). How is the one-liner to > > create a lazy sliding window over a sequence in Clojure? > > There are many functions that operate on sequences which are not built > into Clojure's "for" macro. Perhaps you want partition: > > user=> (partition 3 1 (range 5)) > ((0 1 2) (1 2 3) (2 3 4)) > > This could then be destructured with for if you want: > > user=> (for [[a b c] (partition 3 1 (range 5))] (- c a)) > (2 2 2) >
Yes that's what I was looking for. I made my own function to do that which was unfortunate. Maybe some tooling would have helped me solve the problem I was facing. I think the issue is that when I am programming in a language where you have lots of small functions that you need to compose, you need good tools to find the functions that can usefully be composed. As a beginner, you don't know the name of the functions either (and since a sliding window is not a partition, I don't think it was unexpected that I missed that function). I would like to have a tool that indexed all forms and calculated prob(form_x given the current form context). So when I write "(for [[a b c] _)" and my cursor is at position "_", the tool would inform me that 60% of users have a variable in that position, but 10% use a form starting with (partition...) in that position. If there was a meta-section with usage examples, those could be weighted higher than library code usage. > > 3. The Clojure coding style sets a bad precedent wrt commenting. > > Using Clojure professionally means you need comments. The > > (comment ...) form, although theoretically elegant just doesn't look > > good. There is not a single comment in boot.clj. Is this a > > coincidence? > > Besides (comment ...) there is also ; and documentation strings stored > as meta-data attached to function vars. boot.clj has all but the > first of these. The comment about comments was possibly premature criticism. I just think the style used in boot.clj is too terse. Clojure is a dynamic language and not using comments while using single-letter variable names is extra work on the reader. Some examples of short variable names: m in defn, c in cast, ks in dissoc and disj, e in key and val, fs in comp, 'v' in test. awaits uses agents while send send-off agent-errors etc uses a. Alexander --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---