Skip to content

Instantly share code, notes, and snippets.

View woodrush's full-sized avatar

Hikaru Ikuta woodrush

View GitHub Profile
@woodrush
woodrush / sectorlisp.blc2
Created January 23, 2024 17:01
SectorLISP in BLC2 (which uses Levenshtein coding for De Bruijn indices)
0100010001000100010001000100010101010101010101010101010101010101010100000000000000000000000000000001000100010001010101000000000000000000010001000100010001111010000010111101100000010101010111110011000000000001000101010101111100000000100000000000100000110010111011110000111000101011111000000001100101010110111100001110111011100010001111100010000011011100000001010101010111111000010000111110111001110000010010111101010110000010000011011110000010101010111110111100000000010001111010000011011100000001010101111101101010111000001000001101110111100000101010110000010000000011111100000001010101011111000100001000001000001000001100111110010110111100001011110001111100001110101011111011011111000011101010101100000100000000101010111110101011100111101000111100110000010111111000000011100101111101000110100001011011111000000010101111100001101111000101010101011111011110000000000010101111010000100000000101010111110111111100111100011111000000000101010111110100111101111100111000011111001000010110000010000101101111000011100010110111011101
@woodrush
woodrush / blc-to-blc2.py
Created January 23, 2024 17:00
BLC to BLC2 (which uses Levenshtein variable encoding for De Bruijn indices)
import sys
def leven(n):
if n == 0:
return "0"
ret = ""
c = 0
while True:
c += 1
s = f"{n:b}"[1:]
@woodrush
woodrush / leven.py
Created January 22, 2024 01:38
Visualizing the Levenshtein coding
codes_leven = [
"0",
"10",
"1100",
"1101",
"1110000",
"1110001",
"1110010",
"1110011",
"11101000",
@woodrush
woodrush / krivine.lisp
Last active March 10, 2023 11:47
Krivine machine interpreter based on Binary Lambda Calculus written in LambdaLisp
(defparameter **lambdalisp-suppress-repl** t) ;; Enters script mode and suppresses REPL messages
;; Usage:
;; $ git clone https://github.com/woodrush/lambdalisp
;; $ cd lambdalisp
;; $ make
;; $ ( cat bin/lambdalisp.blc | bin/asc2bin; cat examples/lisplambda.lisp; printf '01010000011101000100010' )
;; | bin/Blc > test/krivine.lisp.out
;;
;; LambdaLisp is available at: https://github.com/woodrush/lambdalisp
@woodrush
woodrush / Makefile
Last active October 13, 2022 16:09
Lisp in Grass using ELVM
INTERPRETER=./grass_ml
ELVM_BASE=build/elvm
all: lisp.w
run: lisp.w $(INTERPRETER)
$(INTERPRETER) $<
$(ELVM_BASE)/Makefile:
mkdir -p build
@woodrush
woodrush / grass.ml
Last active October 12, 2022 20:23 — forked from youz/grass.ml
ocaml implementation of http://www.blue.sky.or.jp/grass/
(* Original implementation by @ytomino: https://gist.github.com/ytomino/1113165 *)
(* Forked by @youz: https://gist.github.com/youz/99d41967e08b8dde8a9199efdb36bee0 *)
(* Forked again by @woodrush: https://gist.github.com/woodrush/3d85a6569ef3c85b63bfaf9211881af6 *)
type token = T_w | T_W | T_v | EOF;;
let rec scan s i = (
let length = String.length s in
if i >= length then length, EOF else
match s.[i] with
| 'W' -> i + 1, T_W
@woodrush
woodrush / rot13.w
Last active October 11, 2022 15:48
ROT13 encipherer/decipherer written in the Grass programming language
wwWWwwWwwvwwWWWwWWWwvwwWWwwWwwvwwWWWwWWWwvwWWwWWWWWwwWwwvwvwwwwwvwvwwWWWwwvwWwww
wWwwwvwvwWWwwwWwwvwvwwwWWwwwWWWWWWWWWWWWWWWWWWWwwwwWWwvwwwWwwwWwwwvwwwWWWwwWwwvw
vwwwWWwWWWWwWWWWWWwvwvwwwwWWWWwwwWwwWWWWWWWwwwwWWwvwvwwwWWWWWWWWWWwWWWWwWWWWwWWW
WWWWwvwvwwwwwWWWWwWWWwWWWWWWWwwwWwwwwwwWWWWWWWWWWwwwWWwvwvwwWWWwwvwvwwwWWWWwwWWW
WwvwvwvwwwwwWWWWWWWWWWWWWWWWWWWWwWWWWWWWWWWWWWWWWWWWwWWWWWWWWWWWWWWWWwWWWWWWwWWW
WWWWWWWWWWWwWWWWWWWWWwWWWWWWWWwwwwwwwWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwWwwwwwwwwwwwwwWwwwWWWWWWWWWWWWWWWWWwwwwwWWwWwwwwwwwwwwwwwwwwww
vwvwwwWWWwWWWwWWWWWWWWWWWWWWWWWWWWWWWWwwwWWwWWWWWWWWwvwvwwWWWWWWwWWWWWWWWWWwwWWw
WWWWWwWWWWWWWwvwvwWWWWWWWWWWWWWWwWWWWWWWWWWWWWWWWWWWwwWWwWWWWWWWWwWWWWWWWwWWWWWW
WwvwvwwWWwWWWwvwwWWwWWWwvwwWWwWWWwvwWwWwwvwwWWwWWWwvwwWWWWwwwWwwwWWWWWWWwWwwwwvw
@woodrush
woodrush / sectorlisp-def.blc
Created September 28, 2022 07:44
SectorLISP with READ, PRINT, and DEF in binary lambda calculus
0001010100010001110011010000111001101000000001000100010001000100010001000100010001010101010101010101010101010101010101010101010111111111001010111111010101110010101111110101101110010101111110101111010010101111110101111011001010111111011010100101011111101101011110010101111110110110110010101111110101011110010101111110101110110010101111110110101100101011111101010110010101111110101101001010111111010110110010101111110101111011100101011111101011110111100101011111101101011100101011111101101101001100111110011111001111100000100101111111011101110010111111101111011100101111111010100110011001111001111000001001011111110111010010111111101110110010111111100000110000011001011111100000110000010010111110000010000011001011110000010000010000000000101100000110000101100000100111111001111100111100000100000000101100000110000101100000110000101100000100001011000001100111111100111111000001000000000010110111100001011011110111000000000000000000000000000000000000100010001000101010101010101010101010111111111111111111111100001011011111111110
@woodrush
woodrush / sectorlisp.blc
Last active September 29, 2022 04:25
SectorLISP with PRINT and READ in binary lambda calculus
0100010001000100010001000100010101010101010101010101010101010101010100000000000000000000000000000001000100010001010101000000000000000000010001000100010001111100000010111110100000010101010111111111000000000000100010101010111111000001000000000001000001100101110111110111001010111111000001100101010110111110111101101110010001111111000000110111000000101010101011111111111111111111111111001111111111111111001110000010010111110010110000010000011011111001010101011111111111111111000000000010001111100000011011100000010101011111111111111100101110000010000011011110111000010101011000001000000001111111111111111111001010101111111000001000001000001000001100111111110110111110101111110111110111100101111111111111110111110111100101011000001000000001010101111111111110111011111111101111111100000010111111111111111111101100101111111111011010000101101111111111111111110010111111011011111100101010101111111111111111100000000000010101111100000100000000101010111111111111111110111011111101111100000010101011111111111011110111111110100001111111
@woodrush
woodrush / meta-metacircular.lisp
Created September 20, 2022 15:40
Meta-Metacircular evaluator for LambdaLisp
;; Original code: https://github.com/jart/sectorlisp/blob/main/lisp.lisp
;; Runs on LambdaLisp: https://github.com/woodrush/lambdalisp
(let ((assoc*) (evcon) (pairlis) (evlis) (apply*) (eval*))
(setq assoc*
(lambda (x y)
(cond ((eq y ()) ())
((eq x (car (car y)))
(cdr (car y)))
((quote t)
(assoc* x (cdr y))))))