1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-25 07:50:27 +00:00

Merge pull request #1252 from primo-ppcg/reverse

Rework `reverse`, again
This commit is contained in:
Calvin Rose 2023-08-12 14:29:23 -05:00 committed by GitHub
commit 79c12e5116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1447,9 +1447,11 @@
byte values, reversed.`
[t]
(var n (length t))
(def ret (array/new-filled n))
(forv i 0 n
(put ret i (in t (-- n))))
(def ret (if (bytes? t)
(buffer/new-filled n)
(array/new-filled n)))
(each v t
(put ret (-- n) v))
ret)
(defn invert