This file contains 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
class LinkedList | |
include Enumerable | |
def initialize(head, tail) | |
@head = head | |
@tail = tail | |
end | |
attr_reader :head | |
attr_reader :tail |
This file contains 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
start.include? x | |
end | |
def each(&block) | |
return to_enum(:each) unless block | |
@lists[0].each(&block) if @lists[0] | |
end | |
def insert(x) |
This file contains 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
magit.git") | |
(:name popup :type elpa) | |
(:name fringe-helper | |
:type http | |
:url "http://nschum.de/src/emacs/fringe-helper/fringe-helper.el" | |
:features fringe-helper | |
:compile "fring-helper.el") | |
(:name flymake) | |
(:name flymake-point) |
This file contains 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
pop_with_fitness = population.map { |individual| | |
[individual, individual.fitness] | |
} | |
Array.new(breeding_pool_size) do | |
norm = pop_with_fitness.map(&:last).max | |
if norm.zero? | |
pop_with_fitness.pop.first | |
else |
This file contains 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
% Un tetris tout à fait normal. | |
% | |
% Mon record est de 7 lignes. | |
% | |
% Le programme est un peu lent au début. | |
% | |
% Je n’ai pas fait en sorte que les blocs commencent à tomber plus vite toutes | |
% les 10 lignes. Aucun être humain ne l’a encore remarqué. Allez savoir | |
% pourquoi. |
This file contains 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
#include <iostream> | |
class Test { | |
public: | |
Test() { | |
instance_count++; | |
} | |
static void printCounter() { std::cout << instance_count << std::endl; } | |
private: |
This file contains 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.Maybe | |
import Data.List | |
import Control.Monad | |
type State = Int | |
data TransitionKey a = Epsilon | Key a | Other | Wildcard deriving (Eq, Show) | |
type Transition a = (State, (TransitionKey a, TransitionKey a)) |
This file contains 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
%%% Monad.oz --- A synax that resembles Haskell's do notation for monads. | |
%% NB: The macros need to be evaluated before the examples can be run | |
declare Maybe Reader State Seq in | |
fun {Seq Monad A B} | |
{Monad.bind A fun {$ _} B end} | |
end | |
%% Syntax: return X |
This file contains 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
def ap(*args, &block) | |
lambda do |recv, *new_args, &new_block| | |
recv.send(*(args + new_args), &(block || new_block)) | |
end | |
end | |
class Object | |
def try_it(*arguments, &block) | |
puts "Called try_it on #{inspect} with #{arguments.inspect} and " + | |
"block: #{block.inspect}" |