Skip to content

Instantly share code, notes, and snippets.

View Reconcyl's full-sized avatar

Reconcyl Reconcyl

View GitHub Profile
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 January 7, 2021 20:06
Test compiler speeds!

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 December 5, 2020 04:01
Serrific macdown theme

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 August 16, 2019 07:46
Mancala Brute Forcer (txti.es/mancala)
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 June 4, 2019 03:08
Underload Interpreter in 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 18:43
Professor at MIT can read minds!
{-# 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 September 16, 2018 22:58
Faster maze generator
//! 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;
@Reconcyl
Reconcyl / maze_generator.py
Last active September 15, 2018 08:32
Maze generator
import random
import time
WALL = " "
GAP = "@"
def split(string, width):
for i in range(0, len(string), width):
yield string[i : i+width]
<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>
@Reconcyl
Reconcyl / gfm_test.md
Last active July 7, 2018 04:51
GFM test

header asd