Skip to content

Instantly share code, notes, and snippets.

@tangentstorm
tangentstorm / explanation.md
Created December 10, 2012 14:11
weird dictionary behavior
@tangentstorm
tangentstorm / recurse.pl0
Created December 10, 2012 15:59
PL/0 to retro compiler with recursion! :)
# program to demonstrate recursion.
# prints a 4-digit binary number
const
digits = 4;
# no parametrs in this language, so we use globals
var
number, # the number to convert to binary
cursor; # the current digit position ( moves high to low )
@tangentstorm
tangentstorm / gist:4313762
Created December 16, 2012 22:34
just experimenting... migrated to an OO style, stripped out a bunch of error handling and just let pascal handle range checking ( by crashing with a stack trace )
{$i xpc.inc}
unit romVDP;
interface uses romFont, SDL, SysUtils, xpc;
{This is a simple soft-core of a text-display processor. It features a
resolution of 99 columns x 40 rows and 256 colours. There exist three
memory areas, the character, attribute and font-data map:
character map (4000 byte)
attribute map (8000 byte)
@tangentstorm
tangentstorm / recurse.pas
Created January 19, 2013 17:54
printing a list (string) backwards with only recursion
{$mode objfpc}
program recurse;
procedure fw( s : string; b : byte = 0 );
begin
if b <= length( s ) then begin
write( s[ b ]);
fw( s, b+1 )
end
end;
@tangentstorm
tangentstorm / generifaces.pas
Created January 19, 2013 18:13
Unit to demonstrate that free pascal does not complain when generic types promise to implement an interface but then do not.
{$mode objfpc}
unit generifaces;
{ Unit to demonstrate that free pascal does not complain
when generic types promise to implement an interface but
then do not. }
interface
type
IFoo = interface
function foo : byte;
@tangentstorm
tangentstorm / noct-test-T00Output.txt
Created January 20, 2013 21:38
Oberon07->Haxe!!!
##
## noct : the nickelsworth oberon07 compiler/transpiler
##
## Work in progress from https://github.com/nickelsworth/noct
##
## This is the first Oberon07 program to be sucessfully
## translated to haxe and executed on haxe's neko vm.
## [0120.2013 03:36PM]
##
MODULE T22WhileElsif;
IMPORT Out;
VAR i : INTEGER;
BEGIN
i := 0;
WHILE i = 6 DO Out.String("C"); Out.Ln; i := 123;
ELSIF i = 0 DO Out.String("A"); Out.Ln; i := -1
ELSIF i < 0 DO Out.String("B"); Out.Ln; i := 6;
@tangentstorm
tangentstorm / FORLOOP.rx
Last active December 11, 2015 11:18
Talk about "build one to throw away"
## OBERON SYNTAX TO COMPILE:
FOR x := start TO goal BY step DO
block
END;
## StringTemplate ( generating retro code ):
for_stmt(id, beg, end, step, block) ::= <<
( FOR ) <id>
( 24-jan-2013 : revectoring experiment in retro )
( ------------------------------------------------------- )
( original goal was to capture a newline-delimited string )
( looking in kernel.rx, i found newlines are converted to )
( strings via remap:whitespace, and i decided to attempt )
( revectoring this word to one that does nothing. )
( )
( had I paid a bit more attention, i might have noticed )
( the variable called 'remapping'. the command: )
( )
@tangentstorm
tangentstorm / rgb.cpp
Created January 25, 2013 07:04
test of string comparisons in c++
#include <iostream>
#include <string>
std::string color;
int main()
{
std::cout << "choose: ( red | blu | grn ) ?: ";
std::cin >> color;
if ( color == "red" ) { std::cout << "RED!"; }