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
#time | |
#r "bin/Release/Streams.Core.dll" | |
open Nessos.Streams.Core | |
let rnd = new System.Random() | |
let data = [|1..10000000|] |> Array.map (fun _ -> int64 <| rnd.Next(1000000)) | |
#r "../../packages/FSharp.Collections.ParallelSeq.1.0/lib/net40/FSharp.Collections.ParallelSeq.dll" | |
open FSharp.Collections.ParallelSeq |
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
#time | |
#r "bin/Release/Streams.Core.dll" | |
open Nessos.Streams.Core | |
let data = [|1..10000000|] |> Array.map int64 | |
#r "../../packages/FSharp.Collections.ParallelSeq.1.0/lib/net40/FSharp.Collections.ParallelSeq.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
;; Anything you type in here will be executed | |
;; immediately with the results shown on the | |
;; right. | |
(def data '({:name "nick" :age 20} {:name "george", :age 30} | |
{:name "giannis", :age 40} {:name "dimitris", :age 50})) | |
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 inline f k = (fun x -> k (x + 1)) | |
let inline g k = (fun x -> k (x + 2)) | |
(f << g) id 1 // 4 |
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 "../packages/FsControl.1.0.8/lib/net40/FsControl.Core.dll" | |
open FsControl.Core.TypeMethods | |
open FsControl.Core.Types | |
let inline result (x:'a): 'Functor'a = Inline.instance Applicative.Pure x | |
let inline (>>=) (x:'Monad'a) (f:'a->'Monad'b) :'Monad'b = Inline.instance (Monad.Bind, x) f | |
let inline traverse (f:'a->'Applicative'b) (t:'Traversable'a) :'Applicative'Traversable'b = Inline.instance (Traversable.Traverse , t) f | |
type MonadBuilder() = | |
member inline b.Return(x) = result 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
// mono --optimize=tailc | |
let fs = [1..1000000] |> List.map (fun i -> (fun k j -> k (i + j))) | |
let f = List.fold (fun f' f -> f f') id fs | |
f 1 // StackOverflow |
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 MyClassBase1<'T> () = | |
abstract member function1 : unit -> unit | |
default u.function1 () = () | |
and MyClassDerived1 () = | |
inherit MyClassBase1<int>() | |
override u.function1 () = base.function1() |
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
public static class EnumerableEx | |
{ | |
public static IEnumerable<R> Select<T1, T2, R>(this IEnumerable<Tuple<T1, T2>> source, Func<T1, T2, R> f) | |
{ | |
return source.Select(t => f(t.Item1, t.Item2)); | |
} | |
} | |
Enumerable.Range(1, 10) | |
.Select(x => Tuple.Create(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
let (|Named|Array|Ptr|Param|) (t : System.Type) = | |
if t.IsGenericType | |
then Named(t.GetGenericTypeDefinition(), t.GetGenericArguments()) | |
elif t.IsGenericParameter | |
then Param(t.GenericParameterPosition) | |
elif not t.HasElementType | |
then Named(t, [| |]) | |
elif t.IsArray | |
then Array(t.GetElementType(), t.GetArrayRank()) | |
elif t.IsByRef |
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
// http://msmvps.com/blogs/jon_skeet/archive/2008/02/26/visualising-the-mandelbrot-set-with-linq-yet-again.aspx | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Windows.Forms; | |
using System.Drawing; | |
using System.Drawing.Imaging; | |
using System.Diagnostics; | |
using LinqOptimizer.CSharp; |