; Should this return the head of the series? I'm thinking no right now.
; Should /skip be the default op and /to makes it absolute?
move: func [
"Moves the first instance of value, if found, to a new position in the series."
series [series!]
value
/head "Move to the head of the series"
/tail "Move to the tail of the series"
/to "Move to an absolute position in the series"
index [number! logic! pair!] "Can be positive, negative, or zero"
/skip "Move forward or backward from the current position"
offset [number! logic! pair!] "Can be positive, negative, or zero"
/part "Move the given number of items"
range [number! series! pair!]
;/all "move all instances of value" ; ???
/local pos dest sw*
] [
sw*: system/words
either none? pos: find/only series value [none] [
either part [
value: copy/part pos range
remove/part pos range
][
value: first pos
remove pos
]
dest: any [
all [head sw*/head series]
all [tail sw*/tail series]
all [to at series index]
all [skip sw*/skip pos offset]
]
either part [insert dest :value] [insert/only dest :value]
]
]
You need to create an account or log in to post comments to this site.