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
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 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
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
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
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
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
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
open System | |
// We can not work with radius of the diamond outside 0 to 25 | |
let CreateRadius (i:int) = | |
match i with | |
| i when i = 0 && i < 26 -> Some i | |
| _ -> None | |
let radius = CreateRadius 20 |> Option.get | |
let axis = [|-radius .. radius|] |
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 foo<'A> = { Name: string; things : 'A list} | |
let bar = { Name = "Bjorn"; things = [1;2;3;4]} | |
let baz = {Name = bar.Name; things = bar.things |> List.map (fun x -> x.ToString())} | |
let baznoworky = { bar with things = (bar.things |> List.map (fun x -> x.ToString()))} |