2020-12-28 14:38:26 +03:00
|
|
|
class list():
|
2020-12-30 04:08:21 +03:00
|
|
|
def __init__():
|
|
|
|
self._list=__builtins__.list_new()
|
|
|
|
def __get__(i):
|
|
|
|
return __builtins__.list_get(self._list,i)
|
|
|
|
def __set__(i,v):
|
|
|
|
return __builtins__.list_set(self._list,i,v)
|
|
|
|
def append(v):
|
|
|
|
return __builtins__.list_append(self._list,v)
|
2020-12-30 09:50:26 +03:00
|
|
|
def __len__():
|
2020-12-30 04:08:21 +03:00
|
|
|
return __builtins__.list_length(self._list)
|
|
|
|
def extend(i):
|
|
|
|
for v in i:
|
|
|
|
self.append(v)
|
2020-12-30 09:50:26 +03:00
|
|
|
return self.__len__()
|
2020-12-30 04:08:21 +03:00
|
|
|
def __str__(self):
|
|
|
|
let b = "["
|
2020-12-30 09:50:26 +03:00
|
|
|
let l = self.__len__()
|
2020-12-30 04:08:21 +03:00
|
|
|
for i=0,i<l,i=i+1:
|
|
|
|
if i>0:
|
|
|
|
b=b+", "
|
|
|
|
b=b+__builtins__.list_get(self._list,i)
|
|
|
|
return b+"]"
|
|
|
|
def __iter__(self):
|
|
|
|
let m = self
|
|
|
|
def I(i):
|
|
|
|
let e=m
|
2020-12-30 09:50:26 +03:00
|
|
|
let l=e.__len__()
|
2020-12-30 04:08:21 +03:00
|
|
|
let x=i
|
|
|
|
def _():
|
|
|
|
if x>=l:
|
|
|
|
return _
|
|
|
|
let o=e[x]
|
|
|
|
x=x+1
|
|
|
|
return o
|
|
|
|
return _
|
|
|
|
return I(0)
|
2020-12-28 13:25:33 +03:00
|
|
|
|
2020-12-28 14:38:26 +03:00
|
|
|
class dict():
|
2020-12-30 04:08:21 +03:00
|
|
|
def __init__(self):
|
|
|
|
self._map = __builtins__.hash_new()
|
|
|
|
def __get__(self, ind):
|
|
|
|
return __builtins__.hash_get(self._map, ind)
|
|
|
|
def __set__(self, ind, val):
|
|
|
|
return __builtins__.hash_set(self._map, ind, val)
|
|
|
|
def __str__(self):
|
|
|
|
let out = "{"
|
|
|
|
let first = True
|
|
|
|
for v in self.keys():
|
|
|
|
if not first:
|
|
|
|
out = out + ", "
|
|
|
|
first = False
|
|
|
|
out = out + v + ": " + self[v]
|
|
|
|
out = out + "}"
|
|
|
|
return out
|
2020-12-30 09:50:26 +03:00
|
|
|
def __len__(self):
|
2020-12-30 04:08:21 +03:00
|
|
|
return __builtins__.hash_count(self._map)
|
|
|
|
def capacity(self):
|
|
|
|
return __builtins__.hash_capacity(self._map)
|
|
|
|
def keys(self):
|
|
|
|
class KeyIterator():
|
|
|
|
def __init__(self, target):
|
|
|
|
self.target = target
|
|
|
|
def __iter__(self):
|
|
|
|
let me = self
|
|
|
|
def makeIter(ind):
|
|
|
|
let m = me.target
|
|
|
|
let c = m.capacity()
|
|
|
|
let i = ind
|
|
|
|
def iter():
|
|
|
|
let out = None
|
|
|
|
while out == None and i < c:
|
|
|
|
out = __builtins__.hash_key_at_index(m._map,i)
|
|
|
|
i = i + 1
|
|
|
|
if out == None:
|
|
|
|
return iter
|
|
|
|
else:
|
|
|
|
return out
|
|
|
|
return iter
|
|
|
|
return makeIter(0)
|
|
|
|
return KeyIterator(self)
|
2020-12-28 13:25:33 +03:00
|
|
|
|
|
|
|
class range:
|
2020-12-30 04:08:21 +03:00
|
|
|
def __init__(self, min, max):
|
|
|
|
self.min = min
|
|
|
|
self.max = max
|
|
|
|
def __iter__(self):
|
|
|
|
let me = self
|
|
|
|
def makeIter(ind):
|
|
|
|
let l = me
|
|
|
|
let i = ind
|
|
|
|
def iter():
|
|
|
|
if i >= l.max:
|
|
|
|
return iter
|
|
|
|
let out = i
|
|
|
|
i = i + 1
|
|
|
|
return out
|
|
|
|
return iter
|
|
|
|
return makeIter(self.min)
|
2020-12-28 13:25:33 +03:00
|
|
|
|
2020-12-30 09:50:26 +03:00
|
|
|
def len(obj=None): return (obj and obj.__len__()) or 0
|
2020-12-30 06:28:18 +03:00
|
|
|
def str(obj=None): return (obj and ("" + obj)) or ""
|
|
|
|
def int(obj=None): return (obj and obj.__int__()) or 0
|
|
|
|
def float(obj=None): return (obj and obj.__float__()) or 0.0
|
|
|
|
def dir(obj): return obj.__dir__()
|
2020-12-28 13:25:33 +03:00
|
|
|
|
2020-12-30 06:28:18 +03:00
|
|
|
export list,dict,range,len,str,int,float,dir
|
2020-12-28 13:25:33 +03:00
|
|
|
|
|
|
|
return object()
|