-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteam.py
68 lines (61 loc) · 1.58 KB
/
team.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
from util import *
from char import *
from time import sleep
__author__ = "John Petersen"
__version__ = "0.0.1"
__license__ = "GNU General Public License 3.0"
class Group(list):
def transform(self, fn):
return Group(fn(x) for x in self)
def life(self):
return Group(*[g for g in self if alive(g)])
def death(self):
return Group(*[g for g in self if not alive(g)])
def __init__(self, *lst):
super().__init__(l for l in lst)
class Teams:
life = []
death = []
def __getitem__(self, k):
return self.life[k]
def __init__(self, *lst):
life = [l for l in lst if dead(l)]
death = [l for l in lst if not dead(l)]
#def fn_id(x, *args, **kwargs):
# return x
#def fn_true(x, *args, **kwargs):
# return True
#def fn_false(x, *args, **kwargs):
# return False
#def fn_negation(f):
# return lambda x, *args, **kwargs : not f(x)
#
#
#def transform(lst, fn = fn_id, pred = fn_true):
# C = type(lst)
# if(issubclass(C, dict)):
# out = C()
# for k,v in lst.items():
# if(pred(v)):
# out[k] = f(v)
# return out
# if(issubclass(C, (list, tuple))):
# out = C()
# for l in lst:
# if(pred(l)):
# out.append(l)
# return out
# return None
def chars(c):
out = Group()
t = type(c)
if(issubclass(t, (list, tuple))):
for ci in c:
out.extend(chars(ci))
elif(issubclass(t, dict)):
for k,v in c.items():
out.append(v)
else:
out.append(c)
return out