Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
public class AckermannFormula | |
{ | |
public static long Ackermann(long m, long n) | |
{ | |
if (m == 0) return (n+1); | |
else if (n == 0) Ackermann(m-1, 1); | |
else return Ackermann(m-1, Ackermann(m, n-1)); | |
} | |
} |
public class AckermannFormulaMemoized | |
{ | |
public static long AckermannMemoized(long m, long n) | |
{ | |
long ans = 0; | |
string key = String.Format("{0},{1}", m, n); | |
if (memory.ContainsKey(key)) { | |
return memory[key]; | |
} else { |
public sealed class SingletonExample | |
{ | |
// internal singleton instance | |
private static SingletonExample _instance; | |
// lock for thread-safety laziness | |
private static readonly object _mutex = new object(); | |
// private empty constuctor | |
private SingletonExample() |
public enum ToyType { Car = 0, House = 1 }; | |
public static class ToysFactory | |
{ | |
private static IToy _newToy { get; set; } | |
public static IToy CreateToy(ToyType type) | |
{ | |
if (type == ToyType.Car) | |
{ |
public class TreeNode<T> where T : IComparable<T> | |
{ | |
public T Value { get; set; } | |
public TreeNode<T> Left { get; set; } | |
public TreeNode<T> Right { get; set; } | |
public TreeNode<T> Parent { get; set; } | |
} | |
public static class TreeTraversalRecursive | |
{ |
public class TreeNode<T> where T : IComparable<T> | |
{ | |
public T Value { get; set; } | |
public TreeNode<T> Left { get; set; } | |
public TreeNode<T> Right { get; set; } | |
public TreeNode<T> Parent { get; set; } | |
} | |
public static class TreeTraversalIterative | |
{ |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
import tornado.web | |
import tornado.ioloop | |
from tornado.options import define, options | |
define('port', default=45000, help='try running on a given port', type=int) | |
def fib(): | |
a, b = 1, 1 | |
while True: | |
yield a |
import itertools | |
# Microkanren programs are 'goal' functions that take in a | |
# state and return a stream of states that satisfy the given goal. | |
# I am interested about microkanren because it presents a logic | |
# programming kernel which fits into a dynamically typed language. | |
# Anything could go as a variable, but I wanted names for variables. | |
class Variable(object): |
#!/usr/bin/python | |
''' | |
Copyright (c) 2014 John Morris <[email protected]> | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |