diff options
author | rubidium <rubidium@openttd.org> | 2014-09-19 20:06:51 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2014-09-19 20:06:51 +0000 |
commit | 79ca66eb673c710432d1f4e51af70730a09a82c8 (patch) | |
tree | 5c26b5456711549c69e6d7c74b6e966072670cb6 /src/3rdparty/squirrel/samples/methcall.nut | |
parent | bd0cd31d4b4e13dcf99c3b4170069d9eb08a91cf (diff) | |
download | openttd-79ca66eb673c710432d1f4e51af70730a09a82c8.tar.xz |
(svn r26853) -Cleanup [Squirrel]: remove some stuff that we never did and especially never should use
Diffstat (limited to 'src/3rdparty/squirrel/samples/methcall.nut')
-rw-r--r-- | src/3rdparty/squirrel/samples/methcall.nut | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/src/3rdparty/squirrel/samples/methcall.nut b/src/3rdparty/squirrel/samples/methcall.nut deleted file mode 100644 index 131d26228..000000000 --- a/src/3rdparty/squirrel/samples/methcall.nut +++ /dev/null @@ -1,61 +0,0 @@ -/*translation of the methcall test from The Great Computer Language Shootout -*/ - -Toggle <- { - bool=null -} - -function Toggle::value() { - return bool; -} - -function Toggle::activate() { - bool = !bool; - return this; -} - -function Toggle::new(startstate) { - local newo=clone this; - newo.bool = startstate; - return newo; -} - -NthToggle <- { - count_max=null - count=0 -} - -function NthToggle::new(start_state,max_counter) -{ - local newo=delegate ::Toggle.new(start_state) : clone this; - newo.count_max <- max_counter - return newo; -} - -function NthToggle::activate () -{ - count+=1 - if (count >= count_max) { - bool = !bool; - count = 0; - } - return this; -} - - -local n = ARGS.len()!=0?ARGS[0].tointeger():1 - -local val = 1; -local toggle = Toggle.new(val); -for (local i=0; i<n; i+=1) { - val = toggle.activate().value(); - -} -print(toggle.value() ? "true\n" : "false\n"); - -val = 1; -local ntoggle = NthToggle.new(val, 3); -for (local i=0; i<n; i+=1) { - val = ntoggle.activate().value(); -} -print(ntoggle.value() ? "true\n" : "false\n"); |