Skip to content

Instantly share code, notes, and snippets.

View Mizzlr's full-sized avatar

Mushtaque Ahamed A Mizzlr

View GitHub Profile
var ZERO = function (f) {
return function(z) {
return z;
};
};
var SUCC = function (n) {
return function (f) {
return function (z) {
return f(n(f)(z));
function numerify(churchNumeral) {
return churchNumeral(function (x) {
return x + 1;
})(0); // f is a function that increments the value by 1; z=0
}
// example
numerify(ZERO) // returns 0
var ONE = SUCC(ZERO)
numerify(ONE) // returns 1
function incr(x) { return x+1;};
var zero = 0;
// so numerify is
function numerify(churchNumeral){
return churchNumeral(incr)(zero);
};
var PLUS = function (n) {
return function(m) {
return function(f) {
return function(z) {
return n(f)(m(f)(z));
};
};
};
};
@Mizzlr
Mizzlr / lsystem.py
Last active February 22, 2019 20:14
import sys, os
import turtle as tt
screen = tt.Screen()
class Lsystem:
"Class to compile and draw lsystem with turtle"
def __init__(self, save_every_frame=False,
speed=0):
self.name = ''
# L-System code for pythagorian tree
variables: A B
constants: [ ] + -
axiom: A
rules: (B->BB) (A->B[+A]-A)
angle: 60
length: 20
Generated code:
[ 0 ] A
[ 1 ] B[+A]-A
[ 2 ] BB[+B[+A]-A]-B[+A]-A
[ 3 ] BBBB[+BB[+B[+A]-A]-B[+A]-A]-BB[+B[+A]-A]-B[+A]-A
[ 4 ] BBBBBBBB[+BBBB[+BB[+B[+A]-A]-B[+A]-A]-BB[+B[+A]-A]-B[+A]-A]-BBBB[+BB[+B[+A]-A]-B[+A]-A]-BB[+B[+A]-A]-B[+A]-A
[ FRWD ] B
[ FRWD ] B
[ PUSH ] ((0.00,-160.00), 90.0)
[ RGHT ] +
[ FRWD ] B
[ PUSH ] ((17.32,-150.00), 30.0)
[ RGHT ] +
[ FRWD ] A
[ POP ] ((17.32,-150.00), 30.0)
[ LEFT ] -
import argparse, re, math, sys, time, os
class HuffmanNode:
"""
Node Object that supports Merging operation as in the
Huffman Encoding Algorithm.
self.list_of_chars: list of characters at a node which share
a common ancestors in the Huffman Tree.
self.count: number of times the element in the list of
_='_=%r;print _%%_';print _%_