when converting file name from kebab case to pascal case, remove extension if there is any
This commit is contained in:
@@ -1,6 +1,16 @@
|
|||||||
structure CollisionTree =
|
structure CollisionTree =
|
||||||
struct
|
struct
|
||||||
local
|
local
|
||||||
|
fun findLastDot (str, pos) =
|
||||||
|
if pos < 0 then ~1
|
||||||
|
else if String.sub (str, pos) = #"." then pos
|
||||||
|
else findLastDot (str, pos - 1)
|
||||||
|
|
||||||
|
fun removeFileExtension str =
|
||||||
|
let val lastDot = findLastDot (str, String.size str - 1)
|
||||||
|
in if lastDot = ~1 then str else String.substring (str, 0, lastDot)
|
||||||
|
end
|
||||||
|
|
||||||
fun finish acc =
|
fun finish acc =
|
||||||
let val acc = List.rev acc
|
let val acc = List.rev acc
|
||||||
in String.implode acc
|
in String.implode acc
|
||||||
@@ -16,10 +26,14 @@ struct
|
|||||||
| loop ([], acc) = finish acc
|
| loop ([], acc) = finish acc
|
||||||
in
|
in
|
||||||
fun kebabCaseToPascalCase str =
|
fun kebabCaseToPascalCase str =
|
||||||
(* capitalise first character in string *)
|
let
|
||||||
case String.explode str of
|
val str = removeFileExtension str
|
||||||
chr :: tl => let val chr = Char.toUpper chr in loop (tl, [chr]) end
|
in
|
||||||
| [] => ""
|
(* capitalise first character in string *)
|
||||||
|
case String.explode str of
|
||||||
|
chr :: tl => let val chr = Char.toUpper chr in loop (tl, [chr]) end
|
||||||
|
| [] => ""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
structure BinTree =
|
structure BinTree =
|
||||||
|
|||||||
Reference in New Issue
Block a user