Skip to content

Instantly share code, notes, and snippets.

@tangentstorm
tangentstorm / gist:4250692
Created December 10, 2012 13:56
floating point exception in retro.c
michal@proton:~/vrx$ ./retro --with recurse.rx
Retro 11.5
ok ( ---------------------------------- )
ok ( runtime library )
ok ( ---------------------------------- )
ok : odd? mod 2 1 = ;
ok ( ---------------------------------- )
ok ( generated code )
ok ( ---------------------------------- )
@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 )
; -- global configuration --------------------------------------
SetTitleMatchMode 1 ; match at start of title.
; -- keyboard --------------------------------------------------
#UseHook
!h::SendPlay,{Left}
!t::SendPlay,{Down}
from operator import add,mul
class nda(list):
"""n-dimensional arrays"""
rot=lambda xs,n: nda(xs[-n:] + xs[:-n][:n] + xs[n:-n]) # rotate
len=lambda xs : nda([len(xs)]) # length
wrp=lambda xs,n: nda([nda(xs[i:i+n]) for i in range(0,len(xs),n)]) # wrap
rsh=lambda xs,n,*ns: nda(sum([w.rsh(*ns) for w in xs.wrp(n)],[]) if ns else xs.wrp(n)) # reshape
prod=lambda xs: reduce(mul, xs) # product
@tangentstorm
tangentstorm / output.txt
Last active December 9, 2015 04:51
shabits.py
goal: 66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925
mine: 66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925
@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]
##