Skip to content

Commit

Permalink
yields are needed for tail-recursion?
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorium committed Jul 7, 2024
1 parent a733a40 commit 11f9b5c
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/FSharp.Data.Runtime.Utilities/NameUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,24 @@ let nicePascalName (s: string) =
| Upper _ -> consume from true (i + 1)
| Lower _ -> consume from false (i + 1)
| _ ->
let r1 = struct (from, i)
let r2 = restart (i + 1)

seq {
yield r1
yield! r2
yield struct (from, i)
yield! restart (i + 1)
}
// Consume are letters of the same kind (either all lower or all upper)
and consume from takeUpper i =
match takeUpper, tryAt s i with
| false, Lower _ -> consume from takeUpper (i + 1)
| true, Upper _ -> consume from takeUpper (i + 1)
| true, Lower _ ->
let r1 = struct (from, (i - 1))
let r2 = restart (i - 1)

seq {
yield r1
yield! r2
yield struct (from, (i - 1))
yield! restart (i - 1)
}
| _ ->
let r1 = struct (from, i)
let r2 = restart i

seq {
yield r1
yield! r2
yield struct (from, i)
yield! restart i
}

// Split string into segments and turn them to PascalCase
Expand Down

0 comments on commit 11f9b5c

Please sign in to comment.