Skip to content

Instantly share code, notes, and snippets.

View kashmervil's full-sized avatar

Aleksandr Kirsanov kashmervil

  • JetBrains
  • Amsterdam
View GitHub Profile
let lawAbidingDisposable = {new IDisposable with
member self.Dispose() = printfn "Disposing"
}
let test = task {
use t = lawAbidingDisposable
()
}
open Trik
open Trik.Junior
open Trik.Junior.Parallel
//Вопрос 1
//Какое название для главной сущности выбрать? Успели ли они привыкнуть к брику?
//из вариантов: robot или brick
printfn "Starting"
open Trik
open Trik.Junior
open Trik.Collections
open Trik.Ports
robot.Led.PowerOff()
robot.Led.SetColor LedColor.Green
@kashmervil
kashmervil / result.cs
Created September 19, 2014 10:59
Неприятный баг в тестовой системе. Особенно заметный при использовании функций с generics-параметрами. Два файла: До загрузки и после
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);
@kashmervil
kashmervil / countDifferentVars.hs
Last active August 29, 2015 14:09
Strange behavior of the course testing system
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
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
using System;
using System.Linq;
using System.Collections.Generic;
namespace Merge
{
class Program
{
public static IEnumerable<int> Merge(IEnumerable<int> a, IEnumerable<int> b)
{
using System;
using System.Collections.Generic;
using System.Linq;
namespace Different
{
class Program
{
private static bool AllDifferent(IEnumerable<int> xs)
{
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>
@kashmervil
kashmervil / agressive_outlining.fs
Created March 10, 2015 16:38
Compiling this takes about 30 sec and generates 45 Mb assembly! Oops
let oops = (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|) (<|)
let two = oops (+) 1 1