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 R2 n = | |
let xs = [-n .. n] | |
seq { for x in xs do for y in xs do yield x,y } | |
let TaxicabNorm (x, y) = abs x + abs y | |
let radius = 10 | |
let indexedLetters = | |
['A' .. 'Z'] |> Seq.mapi (fun i l -> i,l) |
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 Rod = Dagger | Sword | Fork | |
type Plate = GoldPlate | SilverPlate | BronzePlate | |
type Bottom = Rod | Plate | |
type shish<'A> = | |
Bottom of 'A | |
| Onion of shish<'A> | |
| Lamb of shish<'A> | |
| Tomato of shish<'A> | |
let rec isVeg kebab = | |
match kebab with |
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 Rod = Dagger | Sword | Fork | |
type Plate = GoldPlate | SilverPlate | BronzePlate | |
type Bottom = Rod | Plate | |
type shish<'A> = | |
Bottom of 'A | |
| Onion of shish<'A> | |
| Lamb of shish<'A> | |
| Tomato of shish<'A> | |
let a = Onion(Onion(Bottom GoldPlate)) |
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 logResultOfSending (logger: IEventIDLog) (receiverNumber : string) (body : string) (status : SmsStatus) = | |
match status with | |
| Response result -> | |
let logg = logresponse receiverNumber body result | |
match result with | |
| Success -> logg SmsSent.EventId logger.Info | |
| Fail -> logg SmsError.EventId logger.Error | |
| Error ex -> | |
logger.Error(SmsError.EventId, "error sending sms", ex) | |
status |
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 lang = (new LanguageUtil(logger)).getLanguageAndLogIfUnknown evt | |
let wrapContentWithPhonenumber x = (evt.PhoneNumber, x) : FdkSms | |
let smsContent = updatePhoneNumberFormatter evt lang | |
smsContent |> // Start with the contents of a message | |
wrapContentWithPhonenumber |> | |
sms.SendSms |> | |
logResultOfSending logger evt.PhoneNumber smsContent |> | |
throwExceptionsWhenMessagesAreNotSent |
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
module SmsTypes | |
open PSWinCom.Gateway.Client; | |
type SmsStatus = Response of MessageResult | Error of System.Exception | |
type FdkSms = string * string | |
type UnknownError = { Error: string} | |
type SmsLogMessage = { ReceiverNumber : string; |
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
namespace FDK.SmsSender | |
open PSWinCom.Gateway.Client; | |
open SmsTypes; | |
type ISmsService = abstract member SendSms: FdkSms -> SmsStatus | |
type Sender = string | |
type SmsService(sender: Sender, client: IGatewayClient) = | |
interface ISmsService with | |
member this.SendSms fdkSms= | |
let receiverNumber, body = fdkSms |
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
module ant | |
[<EntryPoint>] | |
let main argv = | |
List.fold(fun((x,y),d,b)_-> let a=[|0;1;0;-1;0|] in let p=x+a.[d+1],y+a.[d] in p,(d+if b-set[p]=b then 3 else 1)%4,(b-set[p])+(set[p]-b))((100,100),0,set[])[0..15000] |> printfn "%A" | |
System.Console.ReadLine() |> ignore | |
0 |
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
module ant | |
// The position is a x-y coordinate | |
type Pos = int*int | |
// The set of all points on the board which are black | |
type Blacks = Set<Pos> | |
type Dir = Right | Up | Left | Down | |
// This is the entire game state in one turn | |
type State = Pos * Dir * Blacks |
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 ``In Western Christianity, using the Gregorian calendar, Easter always falls on a Sunday between 22 March and 25 April inclusive``(date: DateTime) = | |
let easter = EasterDay date.Year | |
let firstPossibleDay = new DateTime(date.Year, 3, 22) | |
let lastPossibleDay = new DateTime(date.Year, 4, 25) | |
easter >= firstPossibleDay && easter <= lastPossibleDay && easter.DayOfWeek = DayOfWeek.Sunday |