janet-lang / janet-lang.org

Website for janet
https://janet-lang.org
MIT License
92 stars 58 forks source link

Update destructuring docs with `& more` #153

Closed uvtc closed 2 years ago

uvtc commented 2 years ago

As of v1.20.0, Janet supports & more in destructuring. Update https://janet-lang.org/docs/destructuring.html .

sogaiu commented 2 years ago

Some sample code: def:

$ janet
Janet 1.20.0-40ae2e81 linux/x64 - '(doc)' for help
repl:1:> (def [a b & more] [1 2 3 5 8])
(1 2 3 5 8)
repl:2:> a
1
repl:3:> b
2
repl:4:> more
(3 5 8)

match:

$ janet
Janet 1.20.0-40ae2e81 linux/x64 - '(doc)' for help
repl:1:> (match [1 2 3 5 8] [a b & more] [a b more])
(1 2 (3 5 8))
andrewchambers commented 2 years ago

I think we should include a warning that it does copy and can be expensive.