dotnet new console -o myApp
cd myApp/
dotnet publish -o publish -r linux-x64
# add Dockerfile
docker build . -t myapp:latest
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 Tests | |
open Xunit | |
open Swensen.Unquote | |
open Monad | |
[<Fact>] | |
let ``Maybe bind on Just`` () = | |
Just 5 >>= (((*) 10) >> return') =! Just 50 |
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 Monad | |
/// Maybe (Option) | |
type Maybe<'a> = | |
| Nothing | |
| Just of 'a | |
static member inline doReturn (v) = Just v | |
static member inline doReturnFrom (v) = v |
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
fun doTests() { | |
// println("run test 1") | |
// runTest(::test1) | |
println("\nrun test 2") | |
runTest(::test2) | |
println("\nrun test 3") | |
runTest(::test3) | |
} |
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
static bool isArmstrong(int n) { | |
var digits = n.ToString().Select(x => (int)(x - '0')); | |
return n == digits.Select(x => (int)Math.Pow(x, digits.Count())).Sum(); | |
} |
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
fun mkCycle(min: Int, max: Int) = generateSequence(min) { | |
if (it < max) it + 1 else min | |
} |
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 fibos = Seq.unfold (fun (x, y) -> Some(y, (y, x + y))) (0, 1) |
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 kotlin.coroutines.experimental.buildIterator | |
import kotlin.coroutines.experimental.buildSequence | |
///not tail recursive! | |
fun primes(n: Int = 2): Sequence<Int> = buildSequence<Int> { | |
yield(n) | |
yieldAll(primes(n + 1).filter { x: Int -> x % n != 0 }) | |
} | |
///tail recursive version |
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 Util | |
open System | |
open System.Collections.Generic | |
let toGenericList lst = List<_>(List.toSeq lst) | |
let env = | |
let envVars = | |
Environment.GetEnvironmentVariables() |
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
fun <K> HashMap<K,String>.build() { | |
for (i in this.keys) { | |
val x = i.toString() | |
this.put(i, x) | |
} | |
} | |
/* | |
fun HashMap<Int,String>.build() { | |
this.put(0, "0") |