Permalink
Browse files

fix matrix-take

  • Loading branch information...
1 parent ca30594 commit 793153eabdb024c7fb5fbb6e05f95ceb2d57972a @nooodl committed Jun 23, 2014
Showing with 4 additions and 4 deletions.
  1. +3 −3 gs2.py
  2. +1 −1 gs2c.py
View
@@ -896,13 +896,13 @@ def f(z):
x = self.stack.pop()
self.stack.append([[' ' for ix in xrange(x)]
for iy in xrange(y)])
- elif t == '\x81': # take
+ elif t == '\x81': # matrix-take
y = self.stack.pop()
x = self.stack.pop()
a = self.stack.pop()
def f(a, iy, ix):
- try: return a[iy][ix]
- except IndexError: return ' '
+ row = a[iy % len(a)]
+ return row[ix % len(row)]
self.stack.append([[f(a, iy, ix) for ix in xrange(x)]
for iy in xrange(y)])
elif t == '\x82': # flip
View
@@ -115,7 +115,7 @@
'sub-power-of-2': '\x7e',
'sub-power-of-10': '\x7f',
'empty-matrix': '\x80',
- 'take': '\x81',
+ 'matrix-take': '\x81',
'flip': '\x82',
'transpose': '\x83',
'rotate-cw': '\x84',

0 comments on commit 793153e

Please sign in to comment.