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 datum = "toalla" | |
| let width = 99 | |
| System.String(datum |> Seq.truncate width |> Seq.toArray) | |
| |> sprintf "%-*s" width |
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.Data.Linq" | |
| #r "FSharp.Data.TypeProviders" | |
| open Microsoft.FSharp.Linq | |
| open Microsoft.FSharp.Data.TypeProviders | |
| type Company = SqlDataConnection<ConnectionString = @"Server=(localdb)\Projects;Database=Company;Integrated Security=SSPI"> | |
| let db = Company.GetDataContext() |
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.Text.RegularExpressions | |
| type Clip = System.Windows.Forms.Clipboard | |
| [<System.STAThread>] | |
| do | |
| Regex.Matches(Clip.GetText(), @"\d+", RegexOptions.Singleline) | |
| |> Seq.cast<Match> | |
| |> Seq.map (fun x -> x.Value) | |
| |> Seq.distinct | |
| |> String.concat "," |
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 | |
| type Message= | |
| | GetToken of AsyncReplyChannel<IDisposable> | |
| | Release | |
| let start count = | |
| let agent = | |
| MailboxProcessor.Start(fun inbox -> | |
| let token = |
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 IntelliFactory.WebSharper | |
| open IntelliFactory.WebSharper.Html | |
| open Server.Tonys | |
| [<JavaScript>] | |
| let string chars = System.String (chars |> List.rev |> List.toArray) | |
| [<JavaScript>] | |
| let rec (|Eval|) = function | |
| | Normal (c :: rest) -> |
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
| seq { | |
| for x in elements do | |
| if x % 3 = 0 then | |
| yield x + 12 | |
| } | |
| // instead do: | |
| elements | |
| |> Seq.filter (fun x -> x % 3 = 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
| let asyncDownload1 (url : string) = | |
| let req = HttpWebRequest.Create url | |
| req.BeginGetResponse(fun ar -> | |
| use resp = req.EndGetResponse(ar) | |
| use stream = resp.GetResponseStream() | |
| let result = ref [||] | |
| let buffer = Array.zeroCreate 8192 : byte [] | |
| let rec readAll () = | |
| stream.BeginRead(buffer, 0, buffer.Length, fun ar2 -> | |
| match stream.EndRead ar2 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 OptionBuilder() = | |
| member this.Return x = Some x | |
| member this.Bind(x, f) = | |
| match x with | |
| | Some x -> f x | |
| | None -> None | |
| member this.ReturnFrom x = x | |
| let option = OptionBuilder() |
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 next = | |
| let result = ref 0 | |
| let rnd = System.Random() | |
| let rec roll () = | |
| let old = !result | |
| let next = rnd.Next() | |
| if System.Threading.Interlocked.CompareExchange(result, next, old) = old then | |
| next | |
| else | |
| roll() |
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.Text.RegularExpressions | |
| System.IO.File.ReadAllText @"C:\Documents and Settings\dgrenier\Desktop\PrintInternalOrderDetail.pdf" | |
| |> (fun input -> Regex.Matches(input, @"(?s:Length (\d+).*?stream\r\n(.*?)\r\nendstream)")) | |
| |> Seq.cast<Match> | |
| |> Seq.map (fun m -> int m.Groups.[1].Value, m.Groups.[2].Value) |