Returning from calls 10.5.1

This commit is contained in:
nazrin 2025-06-02 00:06:31 +00:00
parent 10cc5e6e89
commit 7f4946f1e9
10 changed files with 196 additions and 23 deletions

View file

@ -4,17 +4,18 @@ import std.process;
import std.conv;
void main(){
string fib21(){
string fib(uint n){
string r = "";
double a = 0;
double temp;
for(double b = 1; a < 10000; b = temp + b){
for(double b = 1; a <= n; b = temp + b){
r ~= a.to!string ~ "\n";
temp = a;
a = b;
}
return r;
}
assert([ "./lox", "test/fib21.lox" ].execute.output == fib21());
assert([ "./lox", "test/fib21.lox" ].execute.output == fib(6765));
assert([ "./lox", "test/fib10.lox" ].execute.output == fib(34));
}