1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-24 06:03:17 +00:00
A very minimal code change made partition take strings.
This commit is contained in:
Calvin Rose 2019-05-15 00:04:25 -04:00
parent f2313b9959
commit f647ac5631

View File

@ -1047,11 +1047,12 @@
(var i 0) (var nextn n)
(def len (length ind))
(def ret (array/new (math/ceil (/ len n))))
(def slicer (if (bytes? ind) string/slice tuple/slice))
(while (<= nextn len)
(array/push ret (tuple/slice ind i nextn))
(array/push ret (slicer ind i nextn))
(set i nextn)
(+= nextn n))
(if (not= i len) (array/push ret (tuple/slice ind i)))
(if (not= i len) (array/push ret (slicer ind i)))
ret)
###