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 Data.Set | |
countDifferentVars rules variables = | |
size $ Prelude.foldl (\acc (l,r) -> | |
let sets = Data.Set.fold (\s sacc -> if (l `member` s) || (r `member` s) | |
then s:sacc else sacc) [] acc in | |
case sets of [x,y] -> (x `union` y) `insert` (x `delete` (y `delete` acc)) | |
_ -> acc) (fromList (Prelude.map singleton variables)) rules |
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
using System; | |
namespace Integral | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var result = Integral(((x, y) => 1.0), 0, Math.PI/2); | |
Console.WriteLine(result); |
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 Trik | |
open Trik.Junior | |
open Trik.Collections | |
open Trik.Ports | |
robot.Led.PowerOff() | |
robot.Led.SetColor LedColor.Green | |
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 Trik | |
open Trik.Junior | |
open Trik.Junior.Parallel | |
//Вопрос 1 | |
//Какое название для главной сущности выбрать? Успели ли они привыкнуть к брику? | |
//из вариантов: robot или brick | |
printfn "Starting" |
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 lawAbidingDisposable = {new IDisposable with | |
member self.Dispose() = printfn "Disposing" | |
} | |
let test = task { | |
use t = lawAbidingDisposable | |
() | |
} |
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 |
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
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
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) | |