mirror of
https://github.com/janet-lang/janet
synced 2024-11-28 19:19:53 +00:00
rework reverse
This commit is contained in:
parent
ecc4d80a5a
commit
c8c0e112bc
@ -1450,12 +1450,10 @@
|
|||||||
a new array. If a string or buffer is provided, returns an array of its
|
a new array. If a string or buffer is provided, returns an array of its
|
||||||
byte values, reversed.`
|
byte values, reversed.`
|
||||||
[t]
|
[t]
|
||||||
(def len (length t))
|
(var n (length t))
|
||||||
(var n (- len 1))
|
(def ret (array/new-filled n))
|
||||||
(def ret (array/new len))
|
(forv i 0 n
|
||||||
(while (>= n 0)
|
(put ret i (in t (-- n))))
|
||||||
(array/push ret (in t n))
|
|
||||||
(-- n))
|
|
||||||
ret)
|
ret)
|
||||||
|
|
||||||
(defn invert
|
(defn invert
|
||||||
|
Loading…
Reference in New Issue
Block a user