Last active
December 21, 2015 03:39
-
-
Save draegtun/6243869 to your computer and use it in GitHub Desktop.
What I would like to see REMOVE/LAST do.
This file contains hidden or 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
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 | |
] |
This file contains hidden or 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
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