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 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
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
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
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
data Polynomnom = P [Int] | |
instance Show Polynomnom where | |
show (P polynom) = | |
let showp (P []) = "" | |
showp (P xs) = nom ++ showp (P (init xs)) | |
where nom | |
| x == 0 = "" | |
| x < 0 = "-" ++ show (abs x) ++ temp | |
| otherwise = "+" ++ (if (x == 1) then "" else (show (abs x))) ++ temp | |
where x = last xs |
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; | |
using System.Linq; | |
using System.Collections.Generic; | |
namespace Merge | |
{ | |
class Program | |
{ | |
public static IEnumerable<int> Merge(IEnumerable<int> a, IEnumerable<int> b) | |
{ |
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; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace Different | |
{ | |
class Program | |
{ | |
private static bool AllDifferent(IEnumerable<int> xs) | |
{ |
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 | |
let L = 14. // Space between wheels || Your values might be quite different | |
let R = 2.7 // Wheel's radius || | |
let ticksPerRotation = 12000. // ~ amount of ticks is taken by one full rotation | |
let desiredAngle = int ((L/R/4.) * ticksPerRotation) // Math routine to calculate how many ticks is taken to turn | |
type Direction = Forward | Backward | Left | Right | |
// <Twitter boilerplate part> |
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 oops = (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) | |
let two = oops (+) 1 1 |