Skip to content

Instantly share code, notes, and snippets.

class LinkedList
include Enumerable
def initialize(head, tail)
@head = head
@tail = tail
end
attr_reader :head
attr_reader :tail
start.include? x
end
def each(&block)
return to_enum(:each) unless block
@lists[0].each(&block) if @lists[0]
end
def insert(x)
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)
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
@Mon-Ouie
Mon-Ouie / Tetris.oz
Last active December 25, 2015 01:39
% 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.
#include <iostream>
class Test {
public:
Test() {
instance_count++;
}
static void printCounter() { std::cout << instance_count << std::endl; }
private:
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))
%%% 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
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}"