Skip to content

Instantly share code, notes, and snippets.

aaronryank /
Last active Feb 28, 2018
INCOMPLETE RK TO C COMPILER - usage: perl < input.rk > output.c
use Text::ParseWords;
print "typedef void *UNTYPED;\n";
print "#define ARGS UNTYPED args[]\n";
print "#define INT __uint128_t\n";
print "#define STR char *\n\n";
my @variables;
my $variable_count = 0;
my @code;
aaronryank / c-lambda.bash
Last active Jul 10, 2019
Convert a C function to a lambda via executable strings.
View c-lambda.bash
#!/usr/bin/env bash
read -p "Function return type: " val
if [ "$1" != "mini" ]; then
read -p "Function name: " name
read -p "Function argument list: " list
echo "$val $name($list) {" >f.c
echo "Enter code:"
aaronryank / ppcg-answers-integers.txt
Last active Jan 15, 2018
Frequency of languages in my PPCG answers
View ppcg-answers-integers.txt
1 ;#
1 ACL2
1 A Pear Tree
1 Awk
1 Babel
1 BaCon
1 Bob
1 Ceylon
aaronryank / oeis.bash
Last active Dec 21, 2017
Downloads all OEIS sequence lists and formats them into C arrays
View oeis.bash
#!/usr/bin/env bash
# Downloads all OEIS sequence lists and formats them into C arrays
for i in `seq 1 296700`; do
printf -v s "A%.6d" $i
echo $s >/dev/stderr
echo -n "long long int $s[] = {"
wget -qO-$s/list | tr -d '\n' | sed 's/^.*<pre>/<pre>/' | cut -c 7- | cut -f1 -d"]" | tr -d '\n'
echo "};"
aaronryank / quine.exe
Last active Dec 7, 2017
Windows Executable error quine
View quine.exe
The version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.
aaronryank / setup.bash
Last active Dec 8, 2017
Set up a new PC/workstation: wget -qO- | xargs wget
View setup.bash
#!/usr/bin/env bash
# test internet connection
wget -q --spider
if [ ! $? -eq 0 ]; then
echo "No internet connection, exiting..."
exit $?
View humansort.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <limits.h>
// Sort it like a human!
// O(2n)
void humansort(int **list, int size)

Subtract and branch if less than or equal to zero (SUBLEQ)

Subtract the contents of address a from the contents of address b, store the result in address b, and if the result is non-positive, transfer control to address c. If the result is positive, execution continues to the next instruction in the code. So subleq a, b, c would be equivalent to:

mem[b] -= mem[a];
if (mem[b] <= 0)
    goto c;

A variant of subleq is subneg, which is equivalent to subleq except instead of mem[b] <= 0 it performs mem[b] < 0.

aaronryank /
Last active Oct 3, 2017
Turing-complete esoteric languages that are easily to implement -- for