1
/*translation of the methcall test from The Great Computer Language Shootout
8
function Toggle::value() {
12
function Toggle::activate() {
17
function Toggle::new(startstate) {
18
local newo=clone this;
19
newo.bool = startstate;
28
function NthToggle::new(start_state,max_counter)
30
local newo=delegate ::Toggle.new(start_state) : clone this;
31
newo.count_max <- max_counter
35
function NthToggle::activate ()
38
if (count >= count_max) {
46
local n = ARGS.len()!=0?ARGS[0].tointeger():1
49
local toggle = Toggle.new(val);
50
for (local i=0; i<n; i+=1) {
51
val = toggle.activate().value();
54
print(toggle.value() ? "true\n" : "false\n");
57
local ntoggle = NthToggle.new(val, 3);
58
for (local i=0; i<n; i+=1) {
59
val = ntoggle.activate().value();
61
print(ntoggle.value() ? "true\n" : "false\n");