Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
45
Task/Executable-library/Limbo/executable-library-2.limbo
Normal file
45
Task/Executable-library/Limbo/executable-library-2.limbo
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
implement ExecsExeclib;
|
||||
|
||||
include "sys.m"; sys: Sys;
|
||||
include "draw.m";
|
||||
|
||||
ExecsExeclib: module {
|
||||
init: fn(ctxt: ref Draw->Context, args: list of string);
|
||||
};
|
||||
|
||||
# Usually, this would be placed into something like "execlib.m",
|
||||
# but it's fine here.
|
||||
Execlib: module {
|
||||
hailstone: fn(i: big): list of big;
|
||||
};
|
||||
|
||||
init(nil: ref Draw->Context, nil: list of string)
|
||||
{
|
||||
sys = load Sys Sys->PATH;
|
||||
# This program expects that the result of compiling Execlib is execlib.dis,
|
||||
# so you'll need to adjust this line if you used a different filename.
|
||||
lib := load Execlib "execlib.dis";
|
||||
if(lib == nil)
|
||||
die("Couldn't load execlib.dis");
|
||||
|
||||
counts := array[352] of { * => 0 };
|
||||
for(i := 1; i < 100000; i++) {
|
||||
counts[len lib->hailstone(big i)]++;
|
||||
}
|
||||
|
||||
max := 0;
|
||||
maxi := 0;
|
||||
for(i = 1; i < len counts; i++) {
|
||||
if(counts[i] > max) {
|
||||
max = counts[i];
|
||||
maxi = i;
|
||||
}
|
||||
}
|
||||
sys->print("The most common sequence length is %d (encountered %d times)\n", maxi, max);
|
||||
}
|
||||
|
||||
die(s: string)
|
||||
{
|
||||
sys->fprint(sys->fildes(2), "runls: %s: %r", s);
|
||||
raise "fail:errors";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue