Skip to content

RTake

Name - Description Default Type
<input> The sequence from which elements have to be extracted. BytesString[Any]
<output> The extracted elements. Any
Indices One or more indices (counted backwards from the last element) to extract from a sequence. None Int[Int]&Int&[Int]

Works exactly like Take except that the selection indices are counted backwards from the last element in the target sequence. Also, RTake works only on sequences, not on tables.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
;; RTake on sequences
[10 20 30 40] (RTake 1) (Log)
(Assert.Is 30 :Break true)
[10 20 30 40] (RTake [0 1]) (Log)
(Assert.Is [40, 30] :Break true)

;; RTake not valid on tables

;; RTake using a variable as index
1 = .index
[1 2 3 4] (RTake .index) (Log)
(Assert.Is 3 :Break true)
[info] [shards/General/RTake/1.edn] 30
[info] [shards/General/RTake/1.edn] [40 30]
[info] [shards/General/RTake/1.edn] 3