Skip to content

Instantly share code, notes, and snippets.

Avatar

Reconcyl Reconcyl

View GitHub Profile
View Ackermann.hs
import Data.List (foldl')
update :: (Int, [Int]) -> (Int, [Int])
update (n, []) = (n, [])
update (n, 0:ms) = (n+1, ms)
-- optimization: ack(1, n) = n + 2
update (n, 1:ms) = (n+2, ms)
update (0, m:ms) = (1, (m-1):ms)
update (n, m:ms) = (n-1, m:(m-1):ms)
@Reconcyl
Reconcyl / CompileSpeed.md
Last active Jan 7, 2021
Test compiler speeds!
View CompileSpeed.md

This script generates long repetitive programs in various languages (statically typed ones that target native code) and measures the time taken to compile them.

Every program is roughly of the form:

main() {
    var x = 0
    {% n*2 times: %}
    x = 2
    print(i)
    x = 3
@Reconcyl
Reconcyl / README.md
Created Dec 5, 2020
Serrific macdown theme
View README.md

Serrific: a barebones serif MacDown theme

These are just settings that look reasonable to me. Note that this doesn't have any rules for things I don't use.

@Reconcyl
Reconcyl / main.py
Created Aug 16, 2019
Mancala Brute Forcer (txti.es/mancala)
View main.py
SIDE_LENGTH = 6
HOLE_INIT = 4
STONES = 2 * SIDE_LENGTH * HOLE_INIT
class Board:
def __init__(self, holes=None):
if holes:
self.holes = holes
else:
@Reconcyl
Reconcyl / underload.tamsin
Created Jun 4, 2019
Underload Interpreter in Tamsin
View underload.tamsin
# An Underload interpreter written in Tamsin.
# Only supports programs containing only `a^:!S~*()`.
# Concatenate two lists.
concat(nil, R) = return R.
concat(cons(A, AS), R) = concat(AS, R) -> R2 & return cons(A, R2).
# Parse a term into an AST.
term = "a" & return wrap
| "^" & return exec
@Reconcyl
Reconcyl / Assistant.hs
Created May 3, 2019
Professor at MIT can read minds!
View Assistant.hs
{-# LANGUAGE ViewPatterns #-}
import Data.Ord (Down (..))
import Data.List (sort, sortOn, elemIndex, groupBy)
import Data.Function (on)
-- == -- == == -- == --
-- == -- == UTILITY FUNCTIONS == -- == --
-- == -- == == -- == --
@Reconcyl
Reconcyl / maze_generator.rs
Created Sep 16, 2018
Faster maze generator
View maze_generator.rs
//! A faster rewrite of `maze_generator.py` in Rust.
//!
//! The Python version generated a 100x200 maze in about thirty seconds.
//! This version generated a 1000x1000 maze in about five seconds.
extern crate rand;
extern crate itertools;
extern crate integer_sqrt;
use rand::Rng;
View maze_generator.py
import random
import time
WALL = " "
GAP = "@"
def split(string, width):
for i in range(0, len(string), width):
yield string[i : i+width]
View index.html
<html>
<head>
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<body>
<b>Code:</b>
<br/>
<textarea id="code" width="300" height="300"></textarea>