Skip to content

Instantly share code, notes, and snippets.

@SteeveGit
Last active April 3, 2016 17:07
Show Gist options
  • Save SteeveGit/1072d7d56310eb87b3160d154f1b0ca8 to your computer and use it in GitHub Desktop.
Save SteeveGit/1072d7d56310eb87b3160d154f1b0ca8 to your computer and use it in GitHub Desktop.
change: func [
"Changes a value in a series and returns the series after the change."
series [series!] "Series at point to change"
value [any-type!] "The new value"
/part {Limits the amount to change to a given length or position.}
range [number! series! pair!]
/only "Changes a series as a series."
/dup "Duplicates the change a specified number of times."
count [number! pair!]
][
either any-string? :value [
unless any-string? series [only: true]
][
if any-string? series [value: append copy "" :value]
]
if only [value: reduce [:value]]
unless part [range: either series? :value [length? value][1]]
unless dup [count: 1]
insert/dup remove/part series range :value count
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment