You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
351 B

  1. module S = import "lua/string.ml"
  2. open import "prelude.ml"
  3. let split_on ch str =
  4. let len = S.length str
  5. let rec go i acc acc' =
  6. if i > len then
  7. reverse (acc :: acc')
  8. else
  9. let this = S.substring str i i
  10. if this == ch then
  11. go (i + 1) "" (acc :: acc')
  12. else
  13. go (i + 1) (acc ^ this) acc'
  14. go 1 "" []