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 fibn n = | |
let rec loop i a b = | |
if i >= n then a | |
else loop (i+1) b (a+b) | |
loop 0 0 1 |
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 DiscriminatedUnionsReflection | |
open System | |
open System.ComponentModel | |
open Xunit | |
open FSharpPlus | |
open Microsoft.FSharp.Reflection | |
type States = | |
| [<DisplayName("Australian Capital Territory")>] ACT |
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
import scala.annotation.tailrec | |
object interleaving { | |
case class Source[T](name: String, items: Seq[T]) | |
case class Item[T](name: String, value: T) { | |
override def toString: String = s"$name-$value" | |
} | |
val sourcea = Source("A", Seq( 1, 2, 3, 4, 5, 6, 7)) | |
val sourceb = Source("B", Seq( 0, 2, 4, 6, 8,10,12,14,16)) |
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
FROM amazonlinux:latest | |
WORKDIR /app | |
ENV DOTNET_RUNTIME_URL https://go.microsoft.com/fwlink/?linkid=843405 | |
ENV DOTNET_SDK_URL https://go.microsoft.com/fwlink/?linkid=843449 | |
# Install .NET Core - see https://www.microsoft.com/net/core#linuxcentos | |
RUN yum install -y libunwind libicu libuuid zip unzip |
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
def fold[A,B](t: Tree[A], z: B)(f: (B, A) => B)(g: (B,B) => B): B = t match { | |
case Empty() => z | |
case Leaf(a) => f(z, a) | |
case Branch(l: Tree[A], r: Tree[A]) => g(fold(l, z)(f)(g), fold(r, z)(f)(g)) | |
} | |
def fold2[A,B](t: Tree[A], z: B)(f: (B, A) => B)(g: (B,B) => B): B = { | |
@annotation.tailrec | |
def loop(ts: List[(Tree[A], Option[B])], acc: B): B = ts match { | |
case Nil => |
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
import shapeless._ | |
object PrintPoly extends Poly1 { | |
implicit def default[T] = at[(String,T)](_ match { | |
case (s, Some(x)) => () => println(s"option: $s = $x") | |
case (s, None) => () => println(s"option: $s = None") | |
case (s, x) => () => println(s"normal: $s = $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
<Reference Include="FSharp.Data.DesignTime" Condition="$(NCrunch) == '1'"> | |
<HintPath>..\..\packages\FSharp.Data\lib\net40\FSharp.Data.DesignTime.dll</HintPath> | |
</Reference> |
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 filterAsync predicate (items:Async<_> list) = async { | |
let rec loop acc items' = async { | |
match items' with | |
| [] -> return acc | |
| x :: xs -> | |
let! item = x | |
return! loop (if predicate item then item :: acc else acc) xs | |
} | |
return! loop [] items | |
} |
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 rec flatten (token:JToken) = [ | |
if token = null then | |
() | |
else if not token.HasValues then | |
yield (token.Path, token.Type, string token) | |
yield! flatten token.Next | |
else | |
yield! flatten token.First | |
yield! flatten token.Next | |
] |
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
param ($Server, $Database, $User, $Password, $Outfile = "$Database.dbml") | |
set-alias sqlmetal 'C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\SqlMetal.exe' | |
if ($User -ne $null -and $Password -ne $null) { | |
sqlmetal /server:$Server /database:$Database /dbml:$Outfile /user:$User /password:$Password | |
} | |
else { | |
sqlmetal /server:$Server /database:$Database /dbml:$Outfile | |
} |
NewerOlder