Skip to content

Instantly share code, notes, and snippets.

@tangentstorm
tangentstorm / explanation.md
Created Dec 10, 2012
weird dictionary behavior
View explanation.md
@tangentstorm
tangentstorm / recurse.pl0
Created Dec 10, 2012
PL/0 to retro compiler with recursion! :)
View recurse.pl0
# 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 Dec 16, 2012
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 )
View gist:4313762
{$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 Jan 19, 2013
printing a list (string) backwards with only recursion
View recurse.pas
{$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 Jan 19, 2013
Unit to demonstrate that free pascal does not complain when generic types promise to implement an interface but then do not.
View generifaces.pas
{$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;
View noct-test-T00Output.txt
##
## 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]
##
View gist:4587774
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 Dec 11, 2015
Talk about "build one to throw away"
View FORLOOP.rx
## 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>
View RevectoringRiddle.rx
( 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 Jan 25, 2013
test of string comparisons in c++
View rgb.cpp
#include <iostream>
#include <string>
std::string color;
int main()
{
std::cout << "choose: ( red | blu | grn ) ?: ";
std::cin >> color;
if ( color == "red" ) { std::cout << "RED!"; }
You can’t perform that action at this time.