partition improvement

0 views
Skip to first unread message

DiG

unread,
May 8, 2009, 5:02:50 PM5/8/09
to Clojure
Hi all,

Quite often one need to get the last part of partition which is
smaller than the requested partition size. This change also support
another common case where one would like to pad the partition.

Since it is such a small change I am pasting the whole function,
instead of patch, but of cause can produce a patch against core. The
tests are included too.

http://gist.github.com/109002

Regards,
Dimitry Gashinsky (digash)

Stephen C. Gilardi

unread,
May 8, 2009, 5:25:54 PM5/8/09
to clo...@googlegroups.com

On May 8, 2009, at 5:02 PM, DiG wrote:

> Quite often one need to get the last part of partition which is
> smaller than the requested partition size. This change also support
> another common case where one would like to pad the partition.

I like this a lot.

One suggestion:

Keep "coll" as the last argument in all the argument lists

--Steve

Jason Wolfe

unread,
May 9, 2009, 2:36:24 AM5/9/09
to Clojure
See also "partition-all" in clojure.contrib.seq-utils. It isn't as
feature-complete as your version, but is instead a drop-in replacement
for "partition" that always returns the final part (regardless of
whether or not it's long enough).

-Jason

On May 8, 4:02 pm, DiG <i+gmane.comp.java.clojure.u...@gashinsky.com>
wrote:
Reply all
Reply to author
Forward
0 new messages