Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,7 +1,5 @@
import std.stdio;
double sum(ref int i, in int lo, in int hi, lazy double term)
pure @safe {
pure @safe /*nothrow @nogc*/ {
double result = 0.0;
for (i = lo; i <= hi; i++)
result += term();
@ -9,6 +7,8 @@ pure @safe {
}
void main() {
import std.stdio;
int i;
writeln(sum(i, 1, 100, 1.0/i));
sum(i, 1, 100, 1.0/i).writeln;
}

View file

@ -4,8 +4,7 @@ numeric digits 50 /*might as well get some accuracy*/
say sum( 'i', "1", '100', "1/i" ) /*invoke SUM (100th harmonic num)*/
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────SUM subroutine──────────────────────*/
sum: procedure; parse arg i,start,finish,term; sum=0
interpret 'do' i '=' start 'to' finish'; sum=sum+'term'; end'
interpret 'do' i "=" start 'to' finish"; sum=sum+" term '; end'
return sum