Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
Code Snippets: chunk code
[go: Go Back, main page]

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

chunk function

    split: chunk: segment: func [  ; subdivide ?
        {See: CLOS pg. 937. Not that mine works the same, but that was
        the inspiration.}
        series [series!]
        size   [integer!] "The size of the chunks (last chunk may be shorter)"
        /into  "split into a set number (size) of chunks (last chunk may be longer than others)."
        /local ct cur-piece result
    ][
        ct: either into [size] [round/down divide length? series size]
        if into [size: to-integer divide length? series size]
        result: copy []
        if zero? size [return result]
        parse series [
            ct [
                copy cur-piece size skip (append/only result cur-piece) mark:
            ]
        ]
        if any [into  not zero? remainder length? series size] [
            cur-piece: copy mark
            either into
                [append last result cur-piece]
                [append/only result cur-piece]
        ]
        result
    ]
« Newer Snippets
Older Snippets »
1 total  XML / RSS feed