Skip to content

Instantly share code, notes, and snippets.

@draegtun
Last active December 21, 2015 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save draegtun/6243869 to your computer and use it in GitHub Desktop.
Save draegtun/6243869 to your computer and use it in GitHub Desktop.
What I would like to see REMOVE/LAST do.
Rebol []
; see - http://stackoverflow.com/questions/18231434/in-a-series-what-is-the-best-way-of-removing-the-last-element
remove-last: func [
"Removes value(s) from tail of a series."
series [series! port! bitset! none!]
/part range [number!] "Removes to a given length."
][
either part [take/last/part series range] [take/last series]
series
]
Rebol []
do %remove-last.r3
b: [a b c d e f g]
remove-last b ;== [a b c d e f], 'g removed, no change to head
remove-last/part b 2 ;== [a b c d], 'e and 'f removed
b: [a b c d e f g]
append remove-last b 'x ;== [a b c d e f x]
; also
b: [a b c d e f g]
c: append remove-last copy at b 3 'x ; no change to b... c: [c d e f x]
; issues
append remove-last at b 4 'z ; AT is superflorous here... confusing? maybe?? or just someone doing something stupid???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment