langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,7 @@
proc fact(x: int): int =
result = 1
for i in 2..x:
result = result * i
const fact10 = fact(10)
echo(fact10)

View file

@ -0,0 +1,3 @@
...
STRING_LITERAL(TMP122, "3628800", 7);
...

View file

@ -0,0 +1,4 @@
let days_to_seconds n =
let conv = 24 * 60 * 60 in
(n * conv)
;;

View file

@ -0,0 +1,5 @@
let conv = 24 * 60 * 60
let days_to_seconds n =
(n * conv)
;;

View file

@ -0,0 +1,7 @@
bundle Default {
class CompileTime {
function : Main(args : String[]) ~ Nil {
(10*9*8*7*6*5*4*3*2*1)->PrintLine();
}
}
}

View file

@ -0,0 +1,52 @@
'LIBRARY CALLS
'=============
extern lib "../../oxygen.dll"
declare o2_basic (string src)
declare o2_exec (optional sys p) as sys
declare o2_errno () as sys
declare o2_error () as string
extern lib "kernel32.dll"
declare QueryPerformanceFrequency(quad*freq)
declare QueryPerformanceCounter(quad*count)
end extern
'EMBEDDED SOURCE CODE
'====================
src=quote
===Source===
def Pling10 2*3*4*5*6*7*8*9*10
byte a[pling10] 'Pling10 is resolved to a number here at compile time
print pling10
===Source===
'TIMER
'=====
quad ts,tc,freq
QueryPerformanceFrequency freq
QueryPerformanceCounter ts
'COMPILE/EXECUTE
'===============
o2_basic src
if o2_errno then
print o2_error
else
QueryPerformanceCounter tc
print "Compile time: " str((tc-ts)*1000/freq, 1) " MilliSeconds"
o2_exec 'Run the program
end if

View file

@ -0,0 +1,12 @@
functor
import
System Application
prepare
fun {Fac N}
{FoldL {List.number 1 N 1} Number.'*' 1}
end
Fac10 = {Fac 10}
define
{System.showInfo "10! = "#Fac10}
{Application.exit 0}
end

View file

@ -0,0 +1,26 @@
/* Factorials using the pre-processor. */
test: procedure options (main);
%factorial: procedure (N) returns (fixed);
declare N fixed;
declare (i, k) fixed;
k = 1;
do i = 2 to N;
k = k*i;
end;
return (k);
%end factorial;
%activate factorial;
declare (x, y) fixed decimal;
x = factorial (4);
put ('factorial 4 is ', x);
y = factorial (6);
put skip list ('factorial 6 is ', y);
end test;

View file

@ -0,0 +1,8 @@
/* Factorials using the pre-processor. */
test: procedure options (main);
declare (x, y) fixed decimal;
x = 24;
put ('factorial 4 is ', x);
y = 720;
put skip list ('factorial 6 is ', y);
end test;

View file

@ -0,0 +1,2 @@
factorial 4 is 24
factorial 6 is 720

View file

@ -0,0 +1,11 @@
program in out;
const
X = 10*9*8*7*6*5*4*3*2*1 ;
begin
writeln(x);
end;

View file

@ -0,0 +1,2 @@
constant $tenfact = [*] 2..10;
say $tenfact;

View file

@ -0,0 +1 @@
say(BEGIN [*] 2..10);

View file

@ -0,0 +1 @@
a=1*2*3*4*5*6*7*8*9*10

View file

@ -0,0 +1,8 @@
$ include "seed7_05.s7i";
const proc: main is func
local
const integer: factorial is !10;
begin
writeln(factorial);
end func;

View file

@ -0,0 +1,7 @@
#import nat
x = factorial 10
#executable&
comcal = ! (%nP x)--<''>

View file

@ -0,0 +1,2 @@
code IntOut=11;
IntOut(0, 10*9*8*7*6*5*4*3*2);