September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,7 @@
COMPCALA CSECT
L R1,=A(FACT10) r1=10!
XDECO R1,PG
XPRNT PG,L'PG print buffer
BR R14 exit
FACT10 EQU 10*9*8*7*6*5*4*3*2*1 factorial computation
PG DS CL12

View file

@ -0,0 +1,22 @@
MACRO
&LAB FACT &REG,&N parameters
&F SETA 1 f=1
&I SETA 1 i=1
.EA AIF (&I GT &N).EB ea: if i>n then goto eb
&F SETA &F*&I f=f*i
&I SETA &I+1 i=i+1
AGO .EA goto ea
.EB ANOP eb:
MNOTE 0,'Load &REG with &N! = &F' macro note
&LAB L &REG,=A(&F) load reg with factorial
MEND macro end
COMPCALB CSECT
USING COMPCALB,R12 base register
LR R12,R15 set base register
FACT R1,10 macro call
XDECO R1,PG
XPRNT PG,L'PG print buffer
BR R14 exit
PG DS CL12
YREGS
END COMPCALB

View file

@ -0,0 +1,6 @@
// version 1.0.6
const val TEN_FACTORIAL = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2
fun main(args: Array<String>) {
println("10! = $TEN_FACTORIAL")
}

View file

@ -0,0 +1,6 @@
define(`factorial',
`ifelse($1, 0, 1, `eval($1 * factorial(eval($1 - 1)))')')dnl
dnl
BEGIN {
print "10! is factorial(10)"
}

View file

@ -0,0 +1,3 @@
BEGIN {
print "10! is 3628800"
}

View file

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

View file

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

View file

@ -0,0 +1,11 @@
fn factorial(n: i64) -> i64 {
let mut total = 1;
for i in 1..n+1 {
total *= i;
}
return total;
}
fn main() {
println!("Factorial of 10 is {}.", factorial(10));
}

View file

@ -0,0 +1,7 @@
const { [1..10].reduce('*).println(" parse time") }
#fcn fact(N) { [1..N].reduce('*).println(" tokenize time"); ""}
// paste output of fact into source
#tokenize fact(10)
println("compiled program running.");