Skip to content

Commit

Permalink
rework reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
primo-ppcg committed Aug 6, 2023
1 parent ecc4d80 commit c8c0e11
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/boot/boot.janet
Original file line number Diff line number Diff line change
Expand Up @@ -1450,12 +1450,10 @@
a new array. If a string or buffer is provided, returns an array of its
byte values, reversed.`
[t]
(def len (length t))
(var n (- len 1))
(def ret (array/new len))
(while (>= n 0)
(array/push ret (in t n))
(-- n))
(var n (length t))
(def ret (array/new-filled n))
(forv i 0 n
(put ret i (in t (-- n))))
ret)

(defn invert
Expand Down

0 comments on commit c8c0e11

Please sign in to comment.