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
data Eval a | |
instance Monad Eval | |
runEval :: Eval a -> a | |
rpar :: a -> Eval a | |
rseq :: a -> Eval a |
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 Strategy a = a -> Eval a | |
rseq :: Strategy a | |
rpar :: Strategy a | |
r0 :: Strategy a | |
r0 x = return x | |
rdeepseq :: NFData a = > Strategy a | |
rdeepseq x = rseq ( deep 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
open System | |
open System.IO | |
open Mono.Unix | |
open System.Reactive | |
open System.Reactive.Linq | |
open System.Reactive.Subjects | |
let Filestream = new Mono.Unix.StdioFileStream("/home/alex/testFile",FileAccess.Read) | |
//testFile is output for 'history' command in Shell |
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
#!/usr/bin/perl | |
$counter = 0; | |
$max_sub = ""; | |
while (<>) { | |
next if length $_ <= $counter + 1; | |
chomp; | |
my $tmp_str = substr $_, 0, $counter; | |
for $letter (split //,(substr $_, $counter, -1)) { | |
$tmp_str = $tmp_str . $letter; |
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 Program | |
open System | |
open System.Collections.Generic | |
open System.Reactive.Linq | |
open Trik | |
let log s = printfn "%s" s | |
type Distance = Far | Middle | Near |
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 resolve_rule name pat body = | |
let to_id (`PArg pn) = pn in | |
let filtered_pat = List.filter is_PArg pat in | |
if (List.length pat) = (List.length filtered_pat) | |
then `FRule (name >$ (List.map to_id filtered_pat) >= body) | |
else `DPGRule (name, [`PCtr ("AllArgs", pat)], body) | |
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 event = new Event<int>() | |
let evp = event.Publish | |
let rand() = System.Random().Next(100) | |
evp.Add(printfn "event raised with %d") | |
let rec loop() = async { | |
event.Trigger <| rand() | |
System.Threading.Thread.Sleep(3000) | |
printfn "Thread number %A" System.Threading.Thread.CurrentThread.ManagedThreadId | |
return! loop() | |
} |
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.Windows.Forms | |
open System.Reactive.Linq | |
let form = new Form(TopMost = true, Visible = true, Text = "Priv") | |
let event = form.MouseMove | |
event|> Observable.filter (fun x -> (x.X > 100) && (x.Y > 100)) | |
|> Observable.add (fun x -> printfn "x = %d y = %d" x.X x.Y) | |
Application.Run(form) | |
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 | |
[<RequireQualifiedAccessAttribute>] | |
module Observable = | |
let Create(subscription) = { new IObservable<'T> with | |
member x.Subscribe observer = subscription observer} | |
let DistinctUntilChanged(sequence: IObservable<'T> when 'T: comparison) = | |
let prev = ref None |
OlderNewer