add a function to convert from kebab case (expectation for file names) to pascal case (convention used for structures)
This commit is contained in:
@@ -1,5 +1,27 @@
|
|||||||
structure CollisionTree =
|
structure CollisionTree =
|
||||||
struct
|
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 =
|
structure BinTree =
|
||||||
struct
|
struct
|
||||||
datatype 'a bintree =
|
datatype 'a bintree =
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ struct
|
|||||||
SOME line => loadIO (io, str ^ line)
|
SOME line => loadIO (io, str ^ line)
|
||||||
| NONE => str
|
| NONE => str
|
||||||
|
|
||||||
fun convertFile fullPath =
|
fun convertFile (fullPath, filename) =
|
||||||
let
|
let
|
||||||
val io = TextIO.openIn fullPath
|
val io = TextIO.openIn fullPath
|
||||||
val text = loadIO (io, "")
|
val text = loadIO (io, "")
|
||||||
@@ -57,7 +57,7 @@ struct
|
|||||||
()
|
()
|
||||||
else if endsWithDsc path then
|
else if endsWithDsc path then
|
||||||
(* is a file ending with .dsc extension *)
|
(* is a file ending with .dsc extension *)
|
||||||
convertFile folderPath
|
convertFile (folderPath, path)
|
||||||
else
|
else
|
||||||
(* is a file but doesn't end with .dsc, so ignore *)
|
(* is a file but doesn't end with .dsc, so ignore *)
|
||||||
()
|
()
|
||||||
|
|||||||
Reference in New Issue
Block a user