Skip to content

Commit 908b858

Browse files
committed
fixing str:toLower (missing Y); fixing str:slice as well to work with slices of length 0
1 parent 5af195c commit 908b858

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

String.ark

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
(if (= _e "V") (set _e "v")
4242
(if (= _e "W") (set _e "w")
4343
(if (= _e "X") (set _e "x")
44+
(if (= _e "Y") (set _e "y")
4445
(if (= _e "Z") (set _e "z")
4546
(if (= _e "Â") (set _e "â")
4647
(if (= _e "À") (set _e "à")
@@ -58,7 +59,7 @@
5859
(if (= _e "Í") (set _e "í")
5960
(if (= _e "Î") (set _e "î")
6061
(if (= _e "Ï") (set _e "ï")
61-
(if (= _e "Ô") (set _e "ô") ()))))))))))))))))))))))))))))))))))))))))))
62+
(if (= _e "Ô") (set _e "ô") ())))))))))))))))))))))))))))))))))))))))))))
6263
# End conditions
6364
(set _output (+ _output _e))
6465
(set _index (+ _index 1))
@@ -171,20 +172,23 @@
171172
# @param _length the length of the slice
172173
# @author https://github.com/Natendrtfm
173174
###
174-
(let str:slice (fun (_string _startingIndex _length) {
175-
(assert (>= _length 1) "slice length must be greater or equal to 1")
176-
(assert (and (>= _startingIndex 0) (< _startingIndex (len _string))) "slice start index must be in range [0, string length[")
175+
(let str:slice (fun (_string _startingIndex _length)
176+
(if (= _length 0)
177+
""
178+
{
179+
(assert (and (>= _startingIndex 0) (< _startingIndex (len _string))) "slice start index must be in range [0, string length[")
177180

178-
(mut _returnedString "")
179-
(mut _index _startingIndex)
180-
(let _end (if (> _length (len _string)) (len _string) (+ _index _length)))
181+
(mut _returnedString "")
182+
(mut _index _startingIndex)
183+
(let _end (if (> _length (len _string)) (len _string) (+ _index _length)))
181184

182-
(while (< _index _end) {
183-
(set _returnedString (+ _returnedString (@ _string _index)))
184-
(set _index (+ _index 1))
185-
})
186-
_returnedString
187-
}))
185+
(while (< _index _end) {
186+
(set _returnedString (+ _returnedString (@ _string _index)))
187+
(set _index (+ _index 1))
188+
})
189+
_returnedString
190+
})
191+
))
188192

189193
###
190194
# @meta String

0 commit comments

Comments
 (0)