Optimization of F# string manipulation -


I'm just learning F # and converting the library of C # extension methods to F #. I am currently working to implement a function named ConvertTterTurnerCupCase based on C # under implementation :

  public static string conversion freterCuperCase (this string value) {If (string.IsNullOrEmpty (value)) return value; If (value.Length == 1) return value. ToUpper (); Return value Thabstring (0, 1) .User () + value. Thambaring (1); }  

F # implementation

  [& lt; System.endime.complierserve Extension Attribute & gt;] Module Public StringHelper Open System Open System.Collections.Generic Open System. Lynch ConvertHelper (X: Four []) = X with x | [| |] | Zero - & gt; "" | [| Head; |] - & gt; Char.ToUpper (head). Ostring () | [| Head; _ |] - & gt; Char.ToUpper (head) .ToString () + string (x.Skip (1) .toArray ()) [& lt; System.Runtime.CompilerServices.ExtensionAttribute >> Go ConvertFirstLetterToUppercase (Only this: string) = match with this only. "" | Zero - & gt; _this | _ - & gt; Convert helper (_this.ToCharArray ())  

Can someone show me a brief implementation to use more natural F # syntax?

like

 ? [& Lt; System.Runtime.CompilerServices.ExtensionAttribute & gt;] Module Public StringHelper = [& LT; System.Runtime.CompilerServices .ExtensionAttribute & gt;] ConvertFirstLetterToUppercase Go (T: String) = Match with t.ToCharArray (). Zero - & gt; T | [||] - & gt; T | X - & gt; X [0] & lt; - Char.ToUpper (x [0]); System.String (x)  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -