add a function to convert from kebab case (expectation for file names) to pascal case (convention used for structures)

This commit is contained in:
2025-08-26 15:17:10 +01:00
parent 8e4f2f4820
commit 060e3779f5
3 changed files with 24 additions and 2 deletions

View File

@@ -1,5 +1,27 @@
structure CollisionTree =
struct
local
fun finish acc =
let val acc = List.rev acc
in String.implode acc
end
fun loop (#"-" :: chr :: tl, acc) =
let val acc = Char.toUpper chr :: acc
in loop (tl, acc)
end
| loop ([#"-"], acc) = finish acc
| loop (chr :: tl, acc) =
loop (tl, chr :: acc)
| 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
| [] => ""
end
structure BinTree =
struct
datatype 'a bintree =