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
| // int -> Parser<'a, 'u> -> Parser<'a list, 'u> | |
| let count n p = | |
| match n with | |
| | _ when n <= 0 -> preturn [] | |
| | _ -> sequence <| List.replicate n p |
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
| // Parser<('a -> 'b), 'u> -> Parser<'a, 'u> -> Parser<'b, 'u> | |
| let apply fp xp = | |
| pipe2 fp xp (fun f x -> f x) | |
| // ('a -> Parser<'b, 'u>) -> 'a list -> Parser<'b list, 'u> | |
| let traverse f list = | |
| let (<*>) = apply | |
| let retn = preturn | |
| let cons head tail = head :: tail | |
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
| // int -> Parser<'a, 'u> -> Parser<'a, 'u> list | |
| let count n p = | |
| List.replicate n p |
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
| // int -> Parser<'a, 'u> -> Parser<'a list, 'u> | |
| let count n p = | |
| match n with | |
| | _ when n <= 0 -> preturn [] | |
| | _ -> | |
| let tryTake xs = | |
| match xs with | |
| | _ when List.length xs >= n -> preturn <| List.take n xs | |
| | _ -> fail <| sprintf "Expecting %i number of elements" n |
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 countAZ n = regex <| sprintf "[A-Z]{%i}" n | |
| let count09 n = regex <| sprintf "[0-9]{%i}" n |
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
| #r "Newtonsoft.Json" | |
| using System; | |
| using System.Net; | |
| using Newtonsoft.Json; | |
| using System.Collections.Generic; | |
| public static async Task<HttpResponseMessage> Run(HttpRequestMessage request, int orderId, TraceWriter log) | |
| { | |
| log.Info($"Webhook was triggered!"); |
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
| change | |
| |> List.map valueOfCoin | |
| |> List.sum | |
| |> (fun change -> remain + change) | |
| |> (fun actual -> expected = actual) |
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
| change | |
| |> List.map valueOfCoin | |
| |> List.sum | |
| |> (+) remain | |
| |> (=) expected |
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 bind f x = function | |
| | Success x -> f x | |
| | Failure errs -> Failure errs | |
| let (>>=) x f = bind f x |
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 bind twoTrackFunction twoTrackInput = function | |
| | Success result -> twoTrackFunction result | |
| | Failure errors -> Failure errors | |
| let (>>=) twoTrackInput twoTrackFunction = | |
| bind twoTrackInput twoTrackFunction |