Skip to content

Instantly share code, notes, and snippets.

@hodzanassredin
hodzanassredin / DesignByContract.cs
Created October 22, 2011 21:05
Design By contract with types in runtime in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TypesContracts
{
class Program
{
static void Main(string[] args)
@hodzanassredin
hodzanassredin / tryRetry.cs
Created October 24, 2011 19:06
try-retry in c# fault tolerance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FaultTolerance
{
class Program
{
static void Main(string[] args)
@hodzanassredin
hodzanassredin / tryRetryFunc.cs
Created October 24, 2011 19:42
try retry in c# in functional
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FaultTolerance
{
class Program
{
static void Main(string[] args)
@hodzanassredin
hodzanassredin / immutable.cs
Created October 26, 2011 23:26
immutable structures in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Tree
{
class Program
{
static void Main(string[] args)
@hodzanassredin
hodzanassredin / twins.cs
Created October 27, 2011 20:29
twin objects pattern
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Twins
{
class Program
{
static void Main(string[] args)
@hodzanassredin
hodzanassredin / prolog.cs
Created October 29, 2011 18:53
prolog in csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Prolog1
{
class Program
{
static void Main(string[] args)
@hodzanassredin
hodzanassredin / test.scala
Created November 1, 2011 22:21
first code in scala language
package Hodza
abstract class Expr() {}
class TrueExpr extends Expr {}
class FalseExpr extends Expr {}
class Or[T <: Expr,U <: Expr](val left: T, val right:U) extends Expr {}
trait Evaluator[T] {
def eval(expr:T): Boolean
@hodzanassredin
hodzanassredin / mixin-policy.scala
Created November 3, 2011 21:47
c_ polity via mixins
package main
trait PolicyPrint{
def out(str: String) {println(str)}
}
trait PolicyPrintNothing{
def out(str: String) {}
}
@hodzanassredin
hodzanassredin / traits.n
Created November 4, 2011 19:30
traits through proxies
using Nemerle.Collections;
using Nemerle.Text;
using Nemerle.Utility;
using Nemerle.DesignPatterns;
using System;
using System.Collections.Generic;
using System.Console;
using System.Linq;
@hodzanassredin
hodzanassredin / alloc.cs
Created November 21, 2011 10:19
custom linear memory allocator
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Allocators
{
class Program
{