Last active
March 21, 2017 15:41
-
-
Save greggirwin/f58f82eb2ef4e6d9b1c40d3f319b8d83 to your computer and use it in GitHub Desktop.
Round-robin cycling through a series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [] | |
cycler: context [ | |
_data: none | |
_key: none | |
set-data: func [data [block!]][ | |
_data: copy data | |
; Should we make sure the data conforms to our needs? | |
;if (last data) <> (first data) [ | |
append/only _data first _data | |
;] | |
_key: last data | |
] | |
take: does [_key: select/only _data _key] | |
test: does [loop length? _data [probe take]] | |
] | |
cyc: make cycler [] | |
cyc/set-data [0 1 2 3 4 5 6 7 8 9] | |
cyc/test | |
cyc: make cycler [] | |
cyc/set-data [a #test 5x5 8 "key" %file 10%] | |
cyc/test | |
cyc: make cycler [] | |
cyc/set-data [[a #test] [5x5 8] ["key" %file 10%]] | |
cyc/test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment