Created
December 10, 2012 02:15
-
-
Save tangentstorm/4248001 to your computer and use it in GitHub Desktop.
pl/0 to retro compiler
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
Retro 11.5 | |
ok ( ---------------------------------- ) | |
ok ( runtime library ) | |
ok ( ---------------------------------- ) | |
ok : odd? mod 2 1 = ; | |
ok ( ---------------------------------- ) | |
ok ( generated code ) | |
ok ( ---------------------------------- ) | |
ok variables| i | | |
ok variables| n | | |
ok : square i @ n ! n @ n @ * putn cr ; | |
ok 0 | |
ok i | |
ok ! | |
ok [ i @ 10 < ] | |
ok [ [ i @ 1 + i ! square i @ 10 < ] while ] | |
ok ifTrue 1 | |
4 | |
9 | |
16 | |
25 | |
36 | |
49 | |
64 | |
81 | |
100 | |
ok bye |
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
# no parametrs in this language, so we'll use a global for now | |
var i; | |
procedure square; | |
var n; | |
begin | |
n := i; | |
! ( n * n ) | |
end; | |
begin | |
i := 0 ; | |
while i < 10 do begin | |
i := i + 1 ; | |
call square | |
end | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment