Re: RIncater

2011-05-23 Thread Edmund Jackson
Hey Ulises,

Sortof.  The original author is updating thing so that they work more 
cleanly.  In the interim if you want to get it to work modify the project.clj 
to look like this: https://gist.github.com/962673.  Then comes the hard bit.  
The JRI uses native libraries that upon compilation seem to hardlink in the 
directory in which the R dynamic libs are saught.  So you either have to make a 
static link R/Versions/ that points 2.10 to the Current.  Or, and this is 
better, download JRI: http://www.rforge.net/JRI/snapshot/JRI_0.5-1.tar.gz then 
compile up the dynamic libs (thus hardlinking your machine) and move them to 
the appropriate subdirectory of ./native in your clojure project and you should 
be good to go.

 Edmund


On 20 May 2011, at 22:25, Ulises wrote:

 Hi,
 
 Is RIncanter still alive?
 
 Cheers,
 
 U
 
 -- 
 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: Where's incanter chrono?

2011-05-08 Thread Edmund Jackson
I think the code has been under development and is now here: 
https://github.com/getwoven/clj-time as clj-time.

On 8 May 2011, at 05:53, Andreas Kostler wrote:

 Hello all,
 Has incanter.chrono disappeared?
 (use '(incanter core chrono))
 results in
 Could not locate incanter/chrono__init.class or incanter/chrono.clj on
 classpath:
  [Thrown class java.io.FileNotFoundException]
 
 For both incanter 1.2.3 and incanter 1.2.2
 
 Cheers
 Andreas
 
 -- 
 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: Simple things should be simple

2010-09-09 Thread Edmund Jackson
Hi Mike,

Could you perhaps present a counter-example of greater simplicity ?

Edmund

On Thu, Sep 9, 2010 at 4:03 PM, Mike Meyer 
mwm-keyword-googlegroups.620...@mired.org wrote:

 On Thu, 9 Sep 2010 07:46:22 -0700 (PDT)
 Meikel Brandmeyer m...@kotka.de wrote:

  Hi,
 
  I don't know what the full definition of deploy is, but here is an
  example, that should serve as a starting point: http://m.3wa.com/?p=472

 That's a good example of simple things not being simple.

 Before I've seen a single line of code, I see I need to create an
 order of magnitude more lines of boilerplate than lines of code in the
 application using a framework that makes simple things simple.

   mike
 --
 Mike Meyer m...@mired.org
 http://www.mired.org/consulting.html
 Independent Network/Unix/Perforce consultant, email for more information.

 O ascii ribbon campaign - stop html mail - www.asciiribbon.org

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Simple things should be simple

2010-09-09 Thread Edmund Jackson
You assume the presence of a configured web server but not a text editor ?
The only constructive thing I can say is that the set of things that may be
considered simple in the clojure setup above is vastly greater than the
alternative you present.  If the cost is a 4 line 'boilerplate' (and I'm
pointedly not going to compare that to /etc/apache/conf.d) I think its a low
price.

On Thu, Sep 9, 2010 at 4:47 PM, Mike Meyer m...@mired.org wrote:

 On Thu, 9 Sep 2010 16:28:48 +0100
 Edmund Jackson edmundsjack...@gmail.com wrote:

  Hi Mike,
 
  Could you perhaps present a counter-example of greater simplicity ?

 $ cat -  /usr/local/www/apache22/cgi-bin/hello-world.sh
 #!/bin/sh

 echo 'Content-type: text/plain\n'
 echo Hello World
 ^D
 $ chomd 755 /usr/local/www/apache22/cgi-bin/hello-world.sh

 Done. Three lines of source code. 0 lines of framework setup. 1 tool
 (sh). Pretty much the same thing works for python, perl, etc.  It's
 about as robust as can be asked for - that's the nature of
 apache. Performance is going to be mediocre at best. That's the
 trade-off for simplicity.

  mike
 --
 Mike Meyer m...@mired.org
 http://www.mired.org/consulting.html
 Independent Network/Unix/Perforce consultant, email for more information.

 O ascii ribbon campaign - stop html mail - www.asciiribbon.org


-- 
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: Trying to write idiomatic clojure to create vector of vectors

2010-07-23 Thread Edmund Jackson
Hi,

Some time back Lau Jensen blogged something like this.  Its starts here 

http://www.bestinclass.dk/index.clj/2009/10/brians-functional-brain.html

but there are at least two follow ups.  It might spark inspiration if you've 
not yet read it.

 Edmund


On 22 Jul 2010, at 13:37, Rising_Phorce wrote:

 I'm coming from an imperative background and trying to stay away from
 for loops to do the task at hand.  Given a size, I want to create a
 vector of vectors to represent a game board similar to Rich's ants or
 Conway's Game of Life (no wrapping necessary for me).  A couple of
 questions.  I will need to traverse the vectors sequentially but at
 each step there will be lots of sequential back and forward tracking.
 Arrays would be the natural imperative choice, but the docs recommend
 this only for inter-op.  So are vectors the best choice?
 
 Secondly, I figured out how to create a row (a vector of length
 'size'):  (defn make-row [size] (vec (take size (repeat nil
 
 but I can't figure out how to conj 'size' calls to make-row onto
 another empty vector.
 
 I've tried 'map', but then I need a data structure of length 'size' to
 iterate
 
 I've looked at 'doTimes', but haven't been successful in figured out
 how to make it work for this.
 
 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

-- 
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: Getting Clojure into the workplace, how do you do it?

2010-07-06 Thread Edmund Jackson
An exercise in declarative programming...

On 6 Jul 2010, at 17:15, Wilson MacGyver wrote:

 my story isn't a very interesting one. I simply told everyone on the team to
 learn it, because we are going to use it :)
 
 On Tue, Jul 6, 2010 at 4:50 AM, Nick Mudge mud...@gmail.com wrote:
 One of the things I like about Clojure is it is a way to get lisp and
 functional programming into workaday programming work; into the many
 places and businesses that use Java.
 
 I'd be very interested to hear stories or experiences of getting
 Clojure into the workplace and how it was done. That is, convincing
 customers and business people and other programmers that it is okay
 that you start doing your work in Clojure in your job. And similar
 such experiences.
 -- 
 Omnem crede diem tibi diluxisse supremum.
 
 -- 
 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

  Edmund





-- 
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: bioinformatics toolkit in clojure: what would that look like?

2010-06-29 Thread Edmund Jackson
Hi Jan,

Perhaps R's excellent bioconductor project could be mapped nicely into 
Incanter (Clojure's R) ? 

Edmund

On 27 Jun 2010, at 23:15, jandot wrote:

 Hi all,
 
 I have been a ruby user for several years and have contributed to the
 bioruby toolkit for bioinformatics. Lately however I got interested in
 clojure as it's a functional language and should be very good for
 working with the huge datasets we have to handle.
 
 Although there are bioinformatics toolkits for many OO languages
 (biojava, bioperl, biopython and bioruby), nothing similar exists for
 clojure yet. And I'd be interested to start building such toolkit
 while I learn the language. At first for my own use, but maybe
 later... who knows.
 
 Being new to functional languages, I wonder how such a toolkit would
 be best approached. In an OO language you create classes with
 properties and methods that describe one particular entitiy in the
 field. For example: you define a DNASequence class with a name and
 sequence property, and a method to print it out in an international
 standard text format, and another method for translating the DNA
 sequence in that of the resulting protein. Much of the functionality
 of these toolkits is about retrieving a bit of information,
 manipulating it and ultimately writing it to screen/file.
 
 As functional languages are more about verbs than nouns: how could a
 bioinformatics toolkit be idiomatically set up? Would it still be the
 Right Way (TM) to create some type of classes, a-la OO?
 
 For more information on the OO toolkits, see www.bioperl.org, www.biojava.org,
 bioruby.org and biopython.org.
 
 As clojure (especially combined with incanter) seems to be a very good
 candidate for future work in bioinformatics, I would very much welcome
 a little discussion on this.
 
 Many thanks,
 jan.
 
 -- 
 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

  Edmund





-- 
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: Understanding lazy-seq

2010-04-13 Thread Edmund Jackson
Wow - thanks everybody.

On 13 Apr 2010, at 14:32, Rich Hickey wrote:

 
 
 On Apr 12, 7:53 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:
 Hi Edmund,
 
 This is a regression since last Tuesday's commit  
 f81e612cc9ff91ddefc1d86e270cd7f018701802. Thanks for catching it!
 
 Stu
 
 
 
 Dear Clojurians,
 
I have been trying to get a proper grip on the operation of lazy-
 seq and hope somebody will have the time to clarify a point for me.  
 The references indicate that you should not hold onto the head of a  
 lazy sequence as it blocks the GC.  This has lead to me to believe  
 that a lazy sequence, even while being active 'downstream' can be  
 GCd 'upstream'.  Is this so ?
 
 An example:  in this post
 
 http://groups.google.com/group/clojure/browse_thread/thread/57a12f1a0...
 
 in the first version of fibo, the call (nth (fibo) 100) will  
 cause a seq to proceed to the millionth element.  If memory were  
 tight could earlier elements be GC'd before nth had reached the  
 end ?  My understand is that it can.  I ask because on my machine on  
 Clojure 1.2, (nth (fibo) 100) causes a heap overflow which I  
 don't understand.
 
 Thanks in advance,
 
  Edmund
 
 
 Now fixed - thanks for the report!
 
 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
 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
 
 To unsubscribe, reply using remove me as the subject.

  Edmund





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


Understanding lazy-seq

2010-04-12 Thread Edmund Jackson
Dear Clojurians,

I have been trying to get a proper grip on the operation of lazy-seq 
and hope somebody will have the time to clarify a point for me.  The references 
indicate that you should not hold onto the head of a lazy sequence as it blocks 
the GC.  This has lead to me to believe that a lazy sequence, even while being 
active 'downstream' can be GCd 'upstream'.  Is this so ?

An example:  in this post

http://groups.google.com/group/clojure/browse_thread/thread/57a12f1a0dab5e1b/cb3db6e6ac94092f?#cb3db6e6ac94092f

in the first version of fibo, the call (nth (fibo) 100) will cause a seq to 
proceed to the millionth element.  If memory were tight could earlier elements 
be GC'd before nth had reached the end ?  My understand is that it can.  I ask 
because on my machine on Clojure 1.2, (nth (fibo) 100) causes a heap 
overflow which I don't understand.

Thanks in advance,

  Edmund





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

To unsubscribe, reply using remove me as the subject.


Re: Why I have chosen not to employ clojure

2010-03-22 Thread Edmund Jackson
I'd agree with that, I've setup Clojure on Linux, Mac and Windows and I found 
Windows the most difficult.  Granted, I virtually never use Windows, but it 
felt like I was fighting it by being at the command line, but had no choice but 
to be there.

On 22 Mar 2010, at 11:31, Luc Préfontaine wrote:

 Is my first impression right or wrong ?
 
 Is Clojure harder to setup from Windows for beginners ?
 
 Would an installer (.msi) help by hiding Java related details and providing 
 some basic scripts to run it ?
 
 Luc P.
 
 On Mon, 2010-03-22 at 16:48 +0530, Martin DeMello wrote:
 
 On Mon, Mar 22, 2010 at 2:19 PM, Joel Westerberg
 joel.westerb...@gmail.com wrote:
 
  Every time I've started up with a clojure project I've had to spend a few
  hours fiddling with the environment, not that I don't do that with other
  languages, but it would be nice with an officially sanctioned solution for
  setting up a sane environment.
 
 Even better, an officially sanctioned solution expressed both as
 documentation, and as a collection of shell scripts for all the major
 platforms.
 
 (As another non-java-familiar clojure adoptee, classpaths were
 definitely a hurdle)
 
 martin
 
 
 
 -- 
 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
  
 To unsubscribe from this group, send email to 
 clojure+unsubscribegooglegroups.com or reply to this email with the words 
 REMOVE ME as the subject.

  Edmund

Do it with love, l-o-v-e
MJ




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

To unsubscribe from this group, send email to 
clojure+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: Name suggestions

2010-03-18 Thread Edmund Jackson
I love the reference,  but I dunno dude, the word itself sounds venereal !

On 18 Mar 2010, at 14:36, Alexandre Patry wrote:

 
 On Wed, Mar 17, 2010 at 3:08 AM, mac markus.gustavs...@gmail.com wrote:

 After just a little more test and polish I plan on calling clj-native
 1.0. But clj-native is a *really* boring name so I want to change it
 before 1.0 and I don't have very good imagination when it comes to
 these things.
 So I need your help.
 It doesn't have to have anything to do with anything, could just be
 something that sounds funny, like sasquatch, that's a funny word.
 What about cocytus, the deepest level of hell in Dante's inferno.  I guess 
 you cannot go lower level than that :)  And it reflect the pain of leaving 
 clojure to write native code.
 
 There are also the clo-cytus or clocytus variations.
 
 Alexandre
 
 -- 
 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

  Edmund

Do it with love, l-o-v-e
MJ




-- 
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: Full Disclojure - I Need Topics!

2010-01-26 Thread Edmund Jackson
+1 defprotocol, deftype, reify

On 26 Jan 2010, at 00:24, Jeff Rose wrote:

 Thanks a lot for the videos you've done so far.  I watch them all.
 Here are some ideas for shows, from more Clojure centric to just
 interesting:
 
 * defprotocol, deftype, reify, ...
 * data-flow programming
 * pattern matching
 * monads
 * performance tuning (unboxed numbers, type hints, ...?)
 * making a clojure library available to Java and other JVM languages
 * a guided tour of clojure contrib
 * OpenGL and Shaders
 * parser combinators
 * generics
 
 -Jeff
 
 On Jan 25, 6:34 am, Sean Devlin francoisdev...@gmail.com wrote:
 Hello everyone,
 I'm having a blast making the Full Disclojure series.  It's one the
 best projects I've had a chance to work on.
 
 However, there's going to be a problem soon.  I only have a few more
 topics left before I run out.  No more topics, no more videos.
 
 This is where you come in.  I'm interested in what the community (i.e.
 you) would like to see talked about.  It could be the core language,
 contrib, a popular library, your-really-awesome-library-that-you-would-
 like-to-get-exposure, or some development tool.  Bring up anything and
 everything.  If it's interesting enough, I'll try to do an episode on
 it.  There are no bad suggestions.
 
 Thanks in advance,
 Sean
 
 -- 
 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

  Edmund

The future is here. It's just not widely distributed yet
 -- Gibson




-- 
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/SLIME/Emacs questions

2010-01-01 Thread Edmund Jackson
and FWIW I got the whole thing going without ELPA by using the  
instructions here:

http://learnclojure.blogspot.com/2009/11/installing-clojure-on-ubuntu-910-karmic.html

but on OSX.

On 1 Jan 2010, at 11:30, Stefan Kamphausen wrote:

 FWIW I have never touched ELPA but got a setup with SLIME from CVS
 plus SBCL and Clojure.  A rudimentary description can be found at
 http://www.skamphausen.de/cgi-bin/ska/My_Clojure_Setup

 The only part that feels tricky is compiling swank for which I needed
 a Maven setup, IIRC.

 Regards,
 Stefan

 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient  
 with your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

   Edmund

The future is here. It's just not widely distributed yet
  -- Gibson




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

2009-11-09 Thread Edmund Jackson

Here's something based on a similar question I asked in #clojure the  
other day, based on the code Chousuke answered with (all ugliness is  
my fault).

(defn cond [f pred]
   (fn [coll acc outp]
  (if (empty? coll)
(conj outp acc)
(if (pred (first coll))
  (recur (rest coll) (vector (first coll)) (conj outp acc))
  (recur (rest coll) (f acc (first coll)) outp)

((cond conj (partial  5)) [1 2 3 4 5 6 7 9 2 1 2 3] '[] '[])
user= [[1 2 3 4 5] [6] [7] [9 2 1 2 3]]

Edmund

On 7 Nov 2009, at 14:17, Christophe Grand wrote:


 Can I play too?

 Non-lazy version (basically the same as Chouser's with reduce  
 instead of loop):
 (defn partition-when [pred coll]
  (reduce #(if (pred %2)
 (conj %1 [%2])
 (conj (pop %1) (conj (peek %1) %2)))
[[]] coll))

 user= (partition-when odd? (range 1 15))
 [[] [1 2] [3 4] [5 6] [7 8] [9 10] [11 12] [13 14]]
 user= (partition-when even? (range 1 15))
 [[1] [2 3] [4 5] [6 7] [8 9] [10 11] [12 13] [14]]


 And lazy version:
 (defn partition-when [pred coll]
  (let [heads (partial take-while (complement pred))]
(cons (heads coll)
  (mapcat #(when (pred %1) [(cons %1 (heads %2))])
coll (iterate rest (rest coll))

 user= (partition-when odd? (range 1 15))
 (() (1 2) (3 4) (5 6) (7 8) (9 10) (11 12) (13 14))
 user= (partition-when even? (range 1 15))
 ((1) (2 3) (4 5) (6 7) (8 9) (10 11) (12 13) (14))

 Christophe

 On Sat, Nov 7, 2009 at 1:47 AM, Alex Osborne a...@meshy.org wrote:

 Alex Osborne wrote:
 Like Mark's but using split-with instead of split-at:

 (defn partition-when [pred coll]
(lazy-seq
 (when-let [[x  xs] (seq coll)]
   (let [[xs ys] (split-with (complement pred) xs)]
 (cons (cons x xs) (partition-when pred ys))

 Just realised this is almost the same as Warren's -- I had missed
 reading Warren's before posting.  Thought it might be helpful if I
 explain the differences:

 * lazy-seq on the outside of the conditional.  This means the seq is
 fully lazy, so if you never call first/next on it, nothing is ever  
 run.

 * As suggested by others complement instead of NOT.

 * (when (seq coll) ...) instead of (if (empty? coll) () ...).  We can
 simplify things like this as (lazy-seq nil) = () and (seq ()) =  
 nil.

 * Using destructuring instead of (first coll) (next coll).  Makes  
 it a
 bit shorter and is quite useful if you're going to use the result of
 (first coll) or (next coll) multiple times, but in this case it  
 doesn't
 really matter.






 -- 
 Professional: http://cgrand.net/ (fr)
 On Clojure: http://clj-me.cgrand.net/ (en)

 

   Edmund

The future is here. It's just not widely distributed yet
  -- Gibson





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