Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,13 @@
|
|||
'IF' I=1 'THEN' OUTINTEGER(1,I);
|
||||
|
||||
'IF' I<J 'THEN' OUTSTRING(1,'(' : I<J')')
|
||||
'ELSE' OUTSTRING(1,'(' : I>=J')');
|
||||
|
||||
'IF' I>=J 'THEN' 'BEGIN'
|
||||
OUTSTRING(1,'(' I=')');
|
||||
OUTINTEGER(1,I)
|
||||
'END'
|
||||
'ELSE' 'BEGIN'
|
||||
OUTSTRING(1,'(' J=')');
|
||||
OUTINTEGER(1,J)
|
||||
'END'
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
'SWITCH' TARGET:=L1,L2,L3;
|
||||
...
|
||||
'GOTO' TARGET(/J/);
|
||||
L1: OUTSTRING(1,'('AA')');
|
||||
L2: OUTSTRING(1,'('BB')');
|
||||
L3: OUTSTRING(1,'('CC')');
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
begin
|
||||
integer a, b, c;
|
||||
|
||||
a := 1; b := 2; c := 3;
|
||||
|
||||
% algol W has the traditional Algol if-the-else statement %
|
||||
% there is no "elseif" contraction %
|
||||
if a = b
|
||||
then write( "a = b" )
|
||||
else if a = c
|
||||
then write( "a = c" )
|
||||
else write( "a is ", a );
|
||||
|
||||
% if-then-else can also be used in an expression %
|
||||
write( if a < 4 then "lt 4" else "ge 4" );
|
||||
|
||||
% algol W also has a "case" statement, an integer expression is used to %
|
||||
% select the statement to execute. If the expression evaluates to 1, %
|
||||
% the first statement is executed, if 2, the second is executed etc. %
|
||||
% If the expression is less than 1 or greater than the number of %
|
||||
% statements, a run time error occurs %
|
||||
case a + b of
|
||||
begin write( "a + b is one" )
|
||||
; write( "a + b is two" )
|
||||
; write( "a + b is three" )
|
||||
; write( "a + b is four" )
|
||||
end;
|
||||
|
||||
% there is also an expression form of the case: %
|
||||
write( case c - a of ( "one", "two", "three", "four" ) )
|
||||
|
||||
end.
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
function takeWhile(lst, fnTest) {
|
||||
'use strict';
|
||||
var varHead = lst.length ? lst[0] : null;
|
||||
|
||||
return varHead ? (
|
||||
fnTest(varHead) ? [varHead].concat(
|
||||
takeWhile(lst.slice(1), fnTest)
|
||||
) : []
|
||||
) : [];
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
go :- write('Hello, World!'), nl.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
fact(foo).
|
||||
fact(bar).
|
||||
fact(baz).
|
||||
|
||||
go :- fact(booger).
|
||||
go :- fact(bar).
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fact(X) :-
|
||||
( X = foo
|
||||
; X = bar
|
||||
; X = baz ).
|
||||
|
||||
go :-
|
||||
( fact(booger)
|
||||
; fact(bar) ).
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fact(X) :-
|
||||
( X = bar -> write('You got me!'), nl
|
||||
; write(X), write(' is not right!'), nl, fail ).
|
||||
|
||||
go :-
|
||||
( fact(booger)
|
||||
; fact(bar) ).
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
BEGIN
|
||||
INTEGER i,j;
|
||||
i:=1; j:=2;
|
||||
OutText("i ");
|
||||
IF i=1 THEN OutInt(i,1);
|
||||
OutImage;
|
||||
OutInt(i,2); OutInt(j,2);
|
||||
IF i<j THEN OutText(" : i<j") ELSE OutText(" : i>=j");
|
||||
OutImage;
|
||||
IF i>=j THEN BEGIN
|
||||
OutText("i=");
|
||||
OutInt(i,5)
|
||||
END
|
||||
ELSE BEGIN
|
||||
OutText("j=");
|
||||
OutInt(j,5)
|
||||
END;
|
||||
OutImage
|
||||
END
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
BEGIN
|
||||
INTEGER i,j;
|
||||
SWITCH target:=L1,L2,L3;
|
||||
i:=1; j:=2;
|
||||
OutText("::");
|
||||
GOTO target(j);
|
||||
L1: OutText("AA");
|
||||
L2: OutText("BB");
|
||||
L3: OutText("CC");
|
||||
OutImage
|
||||
END
|
||||
Loading…
Add table
Add a link
Reference in a new issue