<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: subdivide code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 18 May 2008 08:03:39 GMT</pubDate>
    <description>DZone Snippets: subdivide code</description>
    <item>
      <title>chunk function</title>
      <link>http://snippets.dzone.com/posts/show/1126</link>
      <description>&lt;code&gt;&lt;br /&gt;    split: chunk: segment: func [  ; subdivide ?&lt;br /&gt;        {See: CLOS pg. 937. Not that mine works the same, but that was&lt;br /&gt;        the inspiration.}&lt;br /&gt;        series [series!]&lt;br /&gt;        size   [integer!] "The size of the chunks (last chunk may be shorter)"&lt;br /&gt;        /into  "split into a set number (size) of chunks (last chunk may be longer than others)."&lt;br /&gt;        /local ct cur-piece result&lt;br /&gt;    ][&lt;br /&gt;        ct: either into [size] [round/down divide length? series size]&lt;br /&gt;        if into [size: to-integer divide length? series size]&lt;br /&gt;        result: copy []&lt;br /&gt;        if zero? size [return result]&lt;br /&gt;        parse series [&lt;br /&gt;            ct [&lt;br /&gt;                copy cur-piece size skip (append/only result cur-piece) mark:&lt;br /&gt;            ]&lt;br /&gt;        ]&lt;br /&gt;        if any [into  not zero? remainder length? series size] [&lt;br /&gt;            cur-piece: copy mark&lt;br /&gt;            either into&lt;br /&gt;                [append last result cur-piece]&lt;br /&gt;                [append/only result cur-piece]&lt;br /&gt;        ]&lt;br /&gt;        result&lt;br /&gt;    ]&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 10 Jan 2006 06:20:13 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1126</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
  </channel>
</rss>
