This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Endo = EndsWith of string*string| NoEnding of string | |
| EndsWith ("a","b") | |
| NoEnding "a" | |
| let breakEndingO (w:string) ending = if w.EndsWith ending then w.[0..w.Length-ending.Length-1],ending else w,"" | |
| let breakEnding (w:string) ending = if w.EndsWith ending then EndsWith (w.[0..w.Length-ending.Length-1],ending) else NoEnding(w) | |
| breakEnding "hellooByInch" "ByInch" | |
| breakEnding "xInch" "Inch" | |
| breakEnding "Inch" "Inch" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 44 bytes! | |
| let rec s n=seq{yield!string n;yield!s(n+1)} | |
| // Usage | |
| s 0 |> Seq.nth 100 | |
| s 0 |> Seq.nth 10000000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// Radians | |
| [<Measure>] type r | |
| let inline unitlessSin value : ^T = sin value | |
| let inline unitlessAsin value : ^T = asin value | |
| let inline unitlessCos value : ^T = cos value | |
| let inline unitlessAcos value : ^T = acos value | |
| let inline unitlessTan value : ^T = tan value | |
| let inline unitlessAtan value : ^T = atan value | |
| let inline unitlessAtan2 (x: ^T1) (y: ^T1) : ^T2 = atan2 x y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let inline f tolerance data = | |
| let two = LanguagePrimitives.GenericOne + LanguagePrimitives.GenericOne | |
| data |> List.mapi (fun i c -> i, c) | |
| |>function | |
| | (_,c)::tl -> | |
| tl | |
| |> List.fold (fun (rest, (min, max), x) (i, c) -> | |
| if abs (x-c) <= tolerance | |
| then rest, (min, max+1), (x+c)/two | |
| else ((min,max),x) :: rest, (i, i), c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open Microsoft.FSharp.Data.UnitSystems.SI.UnitNames | |
| open Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols | |
| open System | |
| open System.Text.RegularExpressions | |
| [<Measure>] type g | |
| let (|Integer|_|) str = | |
| let mutable result = 0 | |
| if Int32.TryParse (str, &result) then Some(result) else None |
NewerOlder