Skip to content

Commit

Permalink
Add rest macro
Browse files Browse the repository at this point in the history
  • Loading branch information
swlkr committed Jan 11, 2020
1 parent 3d559dd commit dd50aef
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/joy/helper.janet
Expand Up @@ -144,3 +144,16 @@
(array? val) (array/slice val 0 (dec (length val)))
(tuple? val) (tuple/slice val 0 (dec (length val)))
:else @[]))


(defmacro rest
`Returns all but the first element in an array/tuple.
Does not maintain input (array or tuple) data structure,
always returns a tuple. Throws on nil.

Example

(rest @[1 2 3]) => (2 3)
(rest [3 2 1]) => (2 1)`
[indexed]
~(drop 1 ,indexed))

0 comments on commit dd50aef

Please sign in to comment.