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 FSharp.Data | |
[<Literal>] | |
let connectionString = | |
@"Data Source=.;Initial Catalog=XXX;Integrated Security=True" | |
[<EntryPoint>] | |
let main argv = | |
let getData pagesize offset = | |
use cmd = new SqlCommandProvider<" |
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 Microsoft.FSharp.Data.TypeProviders | |
open System | |
open RProvider | |
open RProvider.``base`` | |
open RProvider.``stats`` | |
open RProvider.``graphics`` | |
type dbSchema = SqlDataConnection<"Data Source=SECRETSERVER;Initial Catalog=SECRETDB;User id=SECRETUSERPassword=SECRET"> | |
[<EntryPoint>] | |
let main argv = |
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 Profile (name:string, age:int) = | |
let id = System.Guid.NewGuid() | |
let mutable name = name | |
let mutable age = age | |
member this.changeAge (newAge: int) = | |
// crazy business rules | |
age <- newAge | |
member this.Id with get () = id | |
member val Name = name with get, set | |
member this.Age with get () = age |
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 Person = { id: Guid; name: string; age: int} | |
let bjorn = { id=System.Guid.NewGuid(); name="Bjørn Einar"; age=34} | |
let changedName = {bjorn with name = "Bjørn the confused"} | |
let changeAge (p:Person) (newAge:int) = | |
// somecrazybusiness rules with age and using services to check if the | |
// age is really correct and do all kinds of sideeffects | |
{p with age = newAge} | |
let changedAgedBjorn = changeAge changedName 30 |
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 number = Number of int * symbol | End of int | |
and symbol = Plus of number | Minus of number| Join of number | |
let rec genSolutions (s:int) (stopp: int) = seq { | |
if s = stopp then yield End s | |
else for g in genSolutions (s+1) stopp do | |
yield Number(s, Plus (g)) | |
yield Number(s, Minus (g)) | |
yield Number(s, Join (g)) | |
} |
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 symbol = Plus of int * symbol | Minus of int * symbol | Join of int * symbol |End | |
let merge (i1: int) (i2:int) = (int)(sprintf "%d%d" i1 i2) | |
let rec flatten (n: int) (s: symbol) = | |
match s with | |
| Join (a,t) -> flatten (merge n a) t | |
| _ -> (n,s) | |
let rest (symbol:symbol) = | |
match symbol 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 symbol = Number of int | Plus of int * symbol | Minus of int * symbol | Join of int * symbol | |
let merge (i1: int) (i2:int) = (int)(sprintf "%d%d" i1 i2) | |
let rec flattenJoin ((i,s): (int*symbol)) = | |
match s with | |
| Number n -> Number (merge i n) | |
| Plus (n,t) -> Plus (merge i n,t) | |
| Minus (n,t) -> Minus (merge i n,t) | |
| Join (n,t) -> flattenJoin (merge i n,t) |
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 symbol = Number of int | Plus | Minus | |
let merge (i1: int) (i2:int) = (int)(sprintf "%d%d" i1 i2) | |
let rec calc (s: symbol list) : int = | |
match s with | |
| [] -> 0 | |
| [Number x] -> x | |
| Number x :: Number y :: rest -> calc(Number (merge x y) :: rest) | |
| Number x :: rest -> x + calc(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
type symbol = Number of int | Plus of int * symbol | Minus of int * symbol | Noop of int * symbol | |
let merge (i1: int) (i2:int) = (int)(sprintf "%d%d" i1 i2) | |
let rec flattenNoop ((i,s): (int*symbol)) = | |
match s with | |
| Number n -> Number (merge i n) | |
| Plus (n,t) -> Plus (merge i n,t) | |
| Minus (n,t) -> Minus (merge i n,t) | |
| Noop (n,t) -> flattenNoop (merge i n,t) |
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 symbol = Number of int | Plus | Minus | |
let rec calc (s: symbol list) : int = | |
match s with | |
| [] -> 0 | |
| [Number x] -> x | |
| Number x :: Number y :: rest -> calc(Number ((int)(sprintf "%d%d" x y)) :: rest) | |
| Number x :: rest -> x + calc(rest) | |
| Plus :: rest -> + calc(rest) | |
| Minus :: rest -> - calc(rest) |