This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wolfram's 2-state 3-symbol Turing Machine | |
from time import sleep | |
delta = {1: {0: (1, 1, 2), 1: (2, -1, 1), 2: (1, -1, 1)}, | |
2: {0: (2, -1, 1), 1: (2, 1, 2), 2: (0, 1, 1)}} | |
ds = {0: ' ', 1: '.', 2: '*'} | |
tlen = 80 | |
tape, head, state = [0] * tlen, int(tlen / 2) - 9, 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wolfram's 2-state 3-symbol Turing Machine as an Universal TM | |
# with Turtle Graphics | |
from time import sleep | |
from turtle import fd, rt, lt, setpos, pu, pd | |
pu(); setpos(-300, 300); pd(); sleep(5) | |
delta = {1: {0: (1, 1, 2), 1: (2, -1, 1), 2: (1, -1, 1)}, | |
2: {0: (2, -1, 1), 1: (2, 1, 2), 2: (0, 1, 1)}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### | |
#### letLISP-REPL.py: | |
#### A Pure LISP Interpreter | |
#### with dynamic-scope named-let | |
#### in pseudocode-style Python 3 | |
#### | |
#### (C) 2022 TAKIZAWA Yozo | |
#### This code is licensed under CC0, | |
#### Creative Commons 0 as Public Domain | |
#### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### | |
#### letLISP.py: | |
#### A Pure LISP Interpreter | |
#### with dynamic-scope named-let | |
#### in pseudocode-style Python 3 | |
#### | |
#### (C) 2022 TAKIZAWA Yozo | |
#### This code is licensed under CC0. | |
#### https://creativecommons.org/publicdomain/zero/1.0/ | |
#### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### | |
#### ev.py: A Pure LISP Interpreter | |
#### in Pseudocode-style Python 3 | |
#### | |
#### (C) 2022 TAKIZAWA Yozo | |
#### This code is licensed under CC0. | |
#### https://creativecommons.org/publicdomain/zero/1.0/ | |
#### | |
#### <examples> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# One token input function with look-ahead caching | |
stty -icanon | |
LF="$(printf \\012)" | |
get_c1 () { | |
case "$LH" in ("") GC1R=$(dd bs=1 count=1 2>/dev/null) | |
;;(*) GC1R="$LH"; LH="" ;;esac | |
} | |
skip_spaces () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import stdin | |
LH = False | |
def get_token(): | |
def put_c1(x): global LH; LH = x | |
def null_c1(): global LH; LH = False | |
def get_c1(): | |
if not LH: | |
try: return stdin.read(1) | |
except EOFError: pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define *lh* #f) | |
(define (get-token) | |
(define (put-c1 x) (set! *lh* x)) | |
(define (null-c1) (set! *lh* #f)) | |
(define (get-c1) (if *lh* (let ((lh *lh*)) (null-c1) lh) (read-char))) | |
(define (tstring t) (list->string (reverse t))) | |
(define (skip-spaces) | |
(do ((c (get-c1) (get-c1))) | |
((not (member c (string->list " \n\r"))) (put-c1 c)))) | |
(let loop ((c (get-c1)) (t '())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define *lh* #f) | |
(define (get-token) | |
(define (put-c1 x) (set! *lh* x)) | |
(define (null-c1) (set! *lh* #f)) | |
(define (get-c1) (if *lh* (let ((lh *lh*)) (null-c1) lh) (read-char))) | |
(define (tstring t) (list->string (reverse t))) | |
(define (skip-spaces) | |
(do ((c (get-c1) (get-c1))) | |
((not (member c (string->list " \n\r"))) (put-c1 c)))) | |
(let loop ((c (get-c1)) (t '())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%{ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <ctype.h> | |
extern int yylex(void); | |
int yyerror(const char *s) { printf("%s\n", s); return 0; } | |
int node[4096]; int nnum = 1; |