Skip to content

Instantly share code, notes, and snippets.

View sadache's full-sized avatar

Sadek Drobi sadache

View GitHub Profile
module Main (
) where
import Control.Monad.Either
f :: (Monad m) ⇒ Int → m Int
f 0 = fail "I don't like zeros"
f x = return x
namespace TTest
{
using CircularList;
using WithCompus = Char;
//using RobotState = Tuple<IEnumerable<char>, Position>;
class Program
{
static void Main(string[] args)
{
WithCompus meWithCompusToNorth = 'N';
module Space.Rovers
open System
type Direction= N | E | S | W
let direction= function 'N' ->N |'E'->E |'S'->S |'W'->W
|_-> raise (new ArgumentOutOfRangeException())
let swap (x,y)=(y,x)
let rec neighbours = function N -> (W,E)
object Application {
def main(args :Array[String]){
println(Simulator(5,5).execute((Orientations.N,(1,2)),List('G','A','G','A','G','A','G','A','A')))
println(Simulator(5,5).execute((Orientations.E,(3,3)),List('A','A','D','A','A','D','A','D','D','A')))
}
object Orientations {
type Orientation=Char
class Program
{
static IDictionary<string,int> zipCodes= new Dictionary<string,int>{
{"Paris",75}
};
static IDictionary<int, int> population = new Dictionary<int, int>{
{75,100}
};
static int? GetInterstingNumber(string cityName){
@sadache
sadache / default-currying-lifting-idea-in.scala
Created November 20, 2009 05:17
default-currying-lifting-idea-in.scala The idea deserves maybe writing a whole paper about. But this illustrates the basic concept.
object Test {
implicit def lift0[A,B >: Any](a:A):B=>A=_=>a
implicit def lift1[A>: Any,B>: Any,C >: Any](f:A=>B):(C=>A)=>C=>A=>B = h=>c =>f (h(c))
implicit def lift2[A<:Any,B<:Any,C<:Any,D >: scala.Nothing <:scala.Any](f:Function2[A,B,C]):Function3[Function1[D,A],Function1[D,B],D,C] =( h ,g, d)=>f (h(d),g(d))
implicit def curry2[a1 >: scala.Nothing <: scala.Any, a2 >: scala.Nothing <: scala.Any, b >: scala.Nothing <: scala.Any] (f:Function2[a1,a2,b]): scala.Function1[a1, scala.Function1[a2, b]] =Function.curried(f)
implicit def curry3[a1 >: scala.Nothing <: scala.Any, a2 >: scala.Nothing <: scala.Any, a3 >: scala.Nothing <: scala.Any, b >: scala.Nothing <: scala.Any] (f:Function3[a1,a2,a3,b]): scala.Function1[a1, scala.Function1[a2,scala.Function1[a3,b]]] =Function.curried(f)
//implicit def self[A](a:A):A=a
def main(args:Array[String]){