Skip to content

Instantly share code, notes, and snippets.

@ploeh
Created May 15, 2015 18:37
Show Gist options
  • Save ploeh/4f873315fc556f7672f1 to your computer and use it in GitHub Desktop.
Save ploeh/4f873315fc556f7672f1 to your computer and use it in GitHub Desktop.
F# readability test.
let nerdCapsToKebabCase (text : string) =
let charToString index c =
let s = c.ToString().ToLower()
match index, Char.IsUpper c with
| 0, _ -> s
| _, true -> "-" + s
| _ -> s
text |> Seq.mapi charToString |> String.concat ""
@giacomociti
Copy link

Yes, maybe some naming adjustment may help but I find it readable the overall code structure

@cbowdon
Copy link

cbowdon commented May 15, 2015

Yes, but I feel in general top level functions should have return types for readability. It's not always obvious from the name (although it is here).

@jarlestabell
Copy link

Yes. But I agree with @isaacabraham, his extra separation of concerns makes this kind of code slightly faster to intuit if the concepts involved (in this case kebab-case) isn't known to the reader beforehand.

@rojepp
Copy link

rojepp commented May 15, 2015

Yes, readable, but distracting for me. This looks like something I could write just to get something working quickly when I'm really thinking about another problem. When reading, I keep getting distracted by the inefficiencies and will try to fix them in my head before moving on. :)

@blair55
Copy link

blair55 commented May 16, 2015

@bogdangaliceanu
Copy link

Yes, it is readable. After seeing @isaacabraham 's active patterns approach I kind of like that more, but regardless, the original is clear enough.

@aschlapsi
Copy link

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment