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 filelist = pasvRead src_site resp | |
| let sitelist = deserialize "sites" | |
| sitelist |> Seq.filter (fun x -> x <> src_site) | |
| |> Seq.iter (fun x -> distribute src_site rls filelist 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 szer = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter() | |
| let inline serialize obj f = | |
| use str = System.IO.File.Create f | |
| szer.Serialize(str, obj) | |
| let inline deserialize f = | |
| use rdr = System.IO.File.OpenRead f | |
| szer.Deserialize rdr |> unbox |
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 P<'t> = Parser<'t, unit> | |
| type Json = | |
| | JString of string | |
| | JNumber of float | |
| | JBool of bool | |
| | JNull | |
| | JList of Json list | |
| | JObject of Map<string, Json> |
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
| // bad way | |
| let formatOrder blah bleh clientName = | |
| let order = getOrder blah | |
| let message = getMessage bleh | |
| let reseult = | |
| if clientName = "boeing" then | |
| sprintf "<Order orderId=\"%d\"/>" order | |
| else | |
| sprintf "Order.orderId:%d" order | |
| result |
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 init settings = | |
| let getJewel a b = | |
| let rnd m = rand() * (float (settings.JewelTypes - m)) |> floor |> int | |
| let shift j jewl = if jewl >= j then jewl + 1 else jewl | |
| match a, b with | |
| | None, None -> rnd 0 | |
| | None, Some i | |
| | Some i, None -> rnd 1 |> shift i | |
| | Some i, Some j when i = j -> rnd 1 |> shift j | |
| | Some i, Some j -> rnd 2 |> shift (min i j) |> shift (max i j) |
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
| [<JavaScript>] | |
| let lineTo (context : Cvs) x1 y1 x2 y2 = | |
| context.MoveTo (x1, y1) | |
| context.LineTo (x2, y2) | |
| [<JavaScript>] | |
| let horiz context y x1 x2 = lineTo context x1 y x2 y | |
| [<JavaScript>] | |
| let vert context x y1 y2 = lineTo context x y1 x y2 |
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 time f = | |
| let sw = System.Diagnostics.Stopwatch.StartNew() | |
| f () |> ignore | |
| printfn "Took %fs" sw.Elapsed.TotalMilliseconds | |
| time (fun () -> System.Threading.Thread.Sleep 1000) |
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 MessageWithResponse = | |
| | GetNextNumber of AsyncReplyChannel<int> * int | |
| let inbox = | |
| MailboxProcessor.Start <| fun inbox -> | |
| async { | |
| while true do | |
| let! (GetNextNumber(channel, num)) = inbox.Receive() | |
| channel.Reply (num + 1) | |
| };; |
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 "System.Windows.Forms" | |
| open System.Windows.Forms | |
| let form = new Form (Visible = true, TopMost = true) | |
| let button = new Button() | |
| form.Controls.Add button | |
| button.Click.Add <| (fun _ -> MessageBox.Show "Hello" |> ignore) |
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 Status = Active | Standby | Inactive | |
| let status = Active | |
| let isOnline = true | |
| if not isOnline then | |
| printfn "Status is offline or inactive" | |
| else | |
| match status with | |
| | Active -> "Status is active" |