Skip to content

Commit

Permalink
better handling of generators (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mego committed Mar 5, 2017
1 parent af3e72d commit 7ab58bb
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions seriously/SeriouslyCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def S_fn(srs):
if isinstance(a, str):
srs.push(''.join(sorted(a)))
elif isinstance(a, collections.Iterable):
srs.push(sorted(a))
srs.push(sorted([_ for _ in a]))
else:
srs.push(math.sin(a))

Expand All @@ -748,6 +748,7 @@ def sum_fn(srs):

def index_fn(srs):
b,a=srs.pop(),srs.pop()
b = [_ for _ in b]
if a in b:
srs.push(b.index(a))
else:
Expand Down Expand Up @@ -983,15 +984,27 @@ def H_fn(srs):
srs.push("Hello, World!")
else:
a,b = srs.pop(), srs.pop()
srs.push(a[:b])
try:
res = a[:b]
except:
res = []
for i,x in enumerate(a):
if i < b:
res.append(x)
else:
break
srs.push(res)

def t_fn(srs):
a,b = srs.pop(), srs.pop()
if isinstance(b, str):
c = srs.pop()
srs.push(a.translate(str.maketrans(b, c)))
else:
srs.push(a[b:])
try:
srs.push(a[b:])
except:
srs.push([_ for _ in a][b:])

def V_fn(srs):
a,b = srs.pop(), srs.pop()
Expand Down

0 comments on commit 7ab58bb

Please sign in to comment.