我想要创建一个函数,根据给定的字符将字符串分解成字符串列表,但是由于未知的原因,OCaml解释器告诉我,我的第3行(字符6-7 )出现了语法错误,这实际上是我的过滤器的制表。我很困惑。我做错什么了?
let explode s c =
let rec explodeIn s c p l = function
| p + 1 -> (String.sub s 0 p)::l
| _ -> let idx = String.rindex_from s p c in; explodeIn s c (idx - 1) ((String.sub s (idx + 1) (p - idx))::l) (String.index s c)
in
explodeIn s c (String.lentgh - 1) [] (String.index s c)
;;发布于 2017-05-13 14:37:43
p + 1不是有效的模式。
也许你是说i when i = p + 1
编辑:
还有几个错误:
;在in之后无效(第4行)
错误String.lentgh => String.length s (第6行)
https://stackoverflow.com/questions/43954225
复制相似问题