Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

rotate function (See related posts)

    rotate: func [
        "Rotate values in a series."
        series [series!]
        /left   "Rotate left (the default)"
        /right  "Rotate right"
        /part range [number!] "Rotate this many positions"  ; TBD series! support?
        /local offset pad
    ][
        range: any [all [range  range // length? series] 1]
        if any [empty? series  zero? range] [return series]
        either right [
            offset: does [skip tail series negate range]
            pad: copy offset
            head insert head clear offset pad
        ][
            pad: copy/part series range
            append remove/part series range pad
        ]
    ]

You need to create an account or log in to post comments to this site.


Click here to browse all 5146 code snippets

Related Posts