This file contains 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 memoization | |
open System.Collections.Generic | |
open System.Collections.Concurrent | |
let memoization fn = | |
let cache = new Dictionary<_,_>() | |
printfn "counter: %A" cache.Count | |
fun arg -> |
This file contains 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
#load "fibonacci.fsx" | |
open fibonacci | |
open System.Diagnostics | |
let loop_start = 0 | |
let loop_end = 40 | |
let testloop fn = | |
let sw = new Stopwatch() |
This file contains 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 fibonacci | |
open System.Collections.Generic | |
let rec fib n = | |
match n with | |
| 0 | 1 -> n | |
| n -> fib (n-1) + fib (n-2) | |
[<TailCall>] |
This file contains 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 A() = class end | |
type B() = inherit A() | |
type C() = inherit A() | |
let evaluation (obj: A) = | |
match obj with | |
| :? B -> "It's a B" | |
| :? C -> "It's a C" | |
| :? A -> "It's a A" | |
| _ -> "nothing" |
This file contains 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 detect1 x = | |
match x with | |
| 1 -> printfn "Found a 1!" | |
| (var1 : int) -> printfn "%d" var1 | |
let my_list = [0..9] | |
for i in my_list do detect1 i |
This file contains 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 Money = Money of decimal | |
let calcTax (Money price) = Money (price * 0.1m) | |
let p = Money 100m | |
calcTax p |> printfn "%A" |
This file contains 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 TypeMoney = CaseMoney of decimal | |
let calcTax (CaseMoney price) = CaseMoney (price * 0.1m) | |
let p = CaseMoney 100m | |
calcTax p |> printfn "%A" |
This file contains 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 TypeMoney = CaseMoney of decimal | |
let calcTax (param_price: TypeMoney) = | |
//let local_price = match param_price with CaseMoney local_p -> local_p | |
let local_price = match param_price with CaseMoney (local_p) -> local_p | |
CaseMoney (local_price * 0.1m) | |
let p = CaseMoney 100m | |
calcTax p |> printfn "%A" |
This file contains 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 Money = Money of decimal | |
let calcTax (price: Money) = | |
let price = match price with Money p -> p | |
Money (price * 0.1m) | |
let p = Money 100m | |
calcTax p |> printfn "%A" |
This file contains 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
import json | |
import lzma | |
import nltk | |
import random | |
nltk.download('twitter_samples') | |
my_filters = [ | |
{"id": lzma.FILTER_LZMA2, "preset": 9 | lzma.PRESET_EXTREME}, | |
] |
NewerOlder