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 =
|
||||
struct
|
||||
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 =
|
||||
let val acc = List.rev acc
|
||||
in String.implode acc
|
||||
@@ -16,10 +26,14 @@ struct
|
||||
| loop ([], acc) = finish acc
|
||||
in
|
||||
fun kebabCaseToPascalCase str =
|
||||
(* capitalise first character in string *)
|
||||
case String.explode str of
|
||||
chr :: tl => let val chr = Char.toUpper chr in loop (tl, [chr]) end
|
||||
| [] => ""
|
||||
let
|
||||
val str = removeFileExtension str
|
||||
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
|
||||
|
||||
structure BinTree =
|
||||
|
||||
Reference in New Issue
Block a user