June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,66 @@
import extensions.
import system'routines.
import system'collections.
import extensions'routines.
class EquilibriumEnumerator :: Enumerator
{
int left.
int right.
int index.
enumerator en.
multi constructor new : object
<= new enumerator:object.
constructor new(Enumerator en)
[
@en := en.
$self reset.
]
constructor new(BaseEnumerable list)
<= new(list enumerator).
bool next
[
index += 1.
while(en next)
[
var element := en get.
right -= element.
bool found := (left == right).
left += element.
if (found)
[
^ true
].
index += 1.
].
^ false
]
reset
[
en reset.
left := 0.
right := en summarize.
index := -1.
en reset.
]
get = index.
}
program =
[
EquilibriumEnumerator new:(-7, 1, 5, 2, -4, 3, 0);
forEach:printingLn.
].