Rebol 编程/take
外观
< Rebol 编程
TAKE value /part length /last
复制并从序列中删除。(修改)
TAKE 是一个函数值。
- 值 -- (类型:序列端口无)
- /part -- 限制为给定长度或位置
- 长度 -- (类型:数字序列端口对)
- /last -- 从尾部获取
- 捕捉
take: func [ "Copies and removes from series. (Modifies)" [catch] value [series! port! none!] /part "Limits to a given length or position" length [number! series! port! pair!] /last "Take it from the tail end" ][ if value [ either part [ case [ pair? length [ unless image? value [ throw-error 'script 'invalid-part length ] last: none ] any [series? length port? length] [ either same? head value head length [ length: subtract index? length index? value ] [ throw-error 'script 'invalid-part reduce [length] ] ] ] if last [ length: negate length value: tail value ] also copy/part value length remove/part value length ] [ also pick either last [ value: back tail value ] [value] 1 remove value ] ] ]