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

BIN
dsc

Binary file not shown.

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 =

View File

@@ -5,7 +5,7 @@ struct
SOME line => loadIO (io, str ^ line)
| NONE => str
fun convertFile fullPath =
fun convertFile (fullPath, filename) =
let
val io = TextIO.openIn fullPath
val text = loadIO (io, "")
@@ -57,7 +57,7 @@ struct
()
else if endsWithDsc path then
(* is a file ending with .dsc extension *)
convertFile folderPath
convertFile (folderPath, path)
else
(* is a file but doesn't end with .dsc, so ignore *)
()