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 ListComprehensions | |
// sehr einfach! | |
let result = | |
let a = 10 | |
let b = 20 | |
let c = 30 | |
a + b + c | |
// könnte man auch so schreiben: |
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.IO | |
//Directory.GetFiles(@"C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\5.0.11", "*.dll") | |
//|> Array.map (fun f -> $"""#r "{Path.GetFileName(f)}" """) | |
//|> Array.iter (printfn "%s") | |
#I @"C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\5.0.11" | |
#r "Microsoft.AspNetCore.Antiforgery.dll" | |
#r "Microsoft.AspNetCore.Authentication.Abstractions.dll" |
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
Date | Open | High | Low | Close | Volume | |
---|---|---|---|---|---|---|
9-Oct-17 | 75.97 | 76.55 | 75.86 | 76.29 | 11386502 | |
6-Oct-17 | 75.67 | 76.03 | 75.54 | 76.00 | 13959814 | |
5-Oct-17 | 75.22 | 76.12 | 74.96 | 75.97 | 21195261 | |
4-Oct-17 | 74.09 | 74.72 | 73.71 | 74.69 | 13317681 | |
3-Oct-17 | 74.67 | 74.88 | 74.20 | 74.26 | 12190403 | |
2-Oct-17 | 74.71 | 75.01 | 74.30 | 74.61 | 15304762 | |
29-Sep-17 | 73.94 | 74.54 | 73.88 | 74.49 | 17079114 | |
28-Sep-17 | 73.54 | 73.97 | 73.31 | 73.87 | 10883787 | |
27-Sep-17 | 73.55 | 74.17 | 73.17 | 73.85 | 19375099 |
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 | |
let tryParse (s: string) = Nullable(5.0) | |
let div (a: float) (b: float) = Nullable 10.0 | |
let add a b = a + b | |
let num1 = tryParse "5.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
type Update<'env, 'model, 'result> = 'env -> 'model -> 'model * 'result | |
[<AutoOpen>] | |
module UpdateOpens = | |
let inline zero env model = model,() | |
let getModel () : Update<'e, 'm, 'm> = fun _ model -> model,model | |
let getEnv () : Update<'e, 'm, 'e> = fun env model -> model,env | |
let getAll () : Update<'e, 'm, 'e * 'm> = fun env model -> model,(env,model) | |
let updateModel (newModel: 'm) : Update<'e, 'm, unit> = fun env model -> newModel,() |
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
// stolen from: https://fsharpforfunandprofit.com/posts/computation-expressions-builder-part6/ | |
type WhateverBuilder() = | |
member this.Bind(m, f) = m f | |
member this.Return(x) = x | |
member this.ReturnFrom(x) = 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
// R imperative version (count prime numbers) | |
// sieb4 <- function(N) { | |
// | |
// if (N < 2L) return(integer()) | |
// if (N == 2L) return(2L) | |
// toCheck <- seq_len(N) | |
// toCheck[1L] <- 0L | |
// toCheck[c(FALSE, TRUE)] <- 0L | |
// |
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
var l1 = new[] | |
{ | |
new | |
{ | |
name = "Jana", | |
projects = new[] {"p1", "p3"} | |
}, | |
new | |
{ | |
name = "Ronald", |
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 IDisplayable = | |
abstract GetDisplayText: unit -> string | |
type Person = | |
{ age: int | |
name: string } | |
interface IDisplayable with | |
member x.GetDisplayText() = x.name | |
let showValue (x: IDisplayable) = |
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 CurryN = | |
open System | |
module Constraints = | |
/// Constrain 't to be a nested tuple of <'t1,'t2,'t3,'t4,'t5,'t6,'t7,'tr> | |
let inline whenNestedTuple (t: 't) = | |
(^t: (member Item1: 't1) t), (^t: (member Item2: 't2) t), (^t: (member Item3: 't3) t), (^t: (member Item4: 't4) t), (^t: (member Item5: 't5) t), (^t: (member Item6: 't6) t), (^t: (member Item7: 't7) t), (^t: (member Rest: 'tr) t) |