Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2010-02-22 20:55:54 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2010-02-22 20:55:54 (GMT)
commit0e8395eace67c8aaee93d0c04711a371821abb6e (patch)
tree627c46f65be627949b7cdeabe63cb88c71936428
parent728d389f896c128cb5db77262b8779ab84743ea5 (diff)
fixed variable no. of args for Python function
-rw-r--r--tablock.py4
-rw-r--r--taconstants.py7
-rw-r--r--talogo.py24
-rw-r--r--tawindow.py2
4 files changed, 12 insertions, 25 deletions
diff --git a/tablock.py b/tablock.py
index 94f5333..1b79d4b 100644
--- a/tablock.py
+++ b/tablock.py
@@ -485,11 +485,11 @@ class Block:
self.docks = [['number', True, self.svg.docks[2+self._ei][0],
self.svg.docks[2+self._ei][1]],
['number', False, self.svg.docks[0][0],
- self.svg.docks[0][1], '[']]
+ self.svg.docks[0][1]]]
for i in range(self._ei+1):
self.docks.append(['number', False, self.svg.docks[i+1][0],
self.svg.docks[i+1][1]])
- self.docks.append(['unavailable', False, 0, 0, ']'])
+ self.docks.append(['unavailable', False, 0, 0])
def _make_number_style_block(self, svg):
self.svg.expand(self.dx+self.ex, self.ey)
diff --git a/taconstants.py b/taconstants.py
index 892d91b..0eea6aa 100644
--- a/taconstants.py
+++ b/taconstants.py
@@ -124,7 +124,7 @@ PALETTES = [['clean', 'forward', 'back', 'show', 'left', 'right',
'storeinbox1', 'storeinbox2', 'string', 'box1', 'box2', 'box',
'storein', 'start'],
['kbinput', 'push', 'printheap', 'keyboard', 'pop', 'clearheap',
- 'myfunc', 'nop', 'addturtle', 'comment', 'print', 'cartesian',
+ 'myfunc2', 'nop', 'addturtle', 'comment', 'print', 'cartesian',
'width','height', 'polar', 'sandwichtop', 'sandwichbottom'],
['journal', 'audio', 'description', 'savepix', 'hideblocks',
'showblocks', 'fullscreen', 'picturelist', 'picture1x1a',
@@ -408,7 +408,7 @@ PRIMITIVES = {
'list':'bulletlist',
'minus2':'minus',
'myfunc':'myfunction',
- 'myfunc2':'myfunc',
+ 'myfunc2':'myfunction',
'nop':'userdefined',
'not':'not',
'orange':'orange',
@@ -537,7 +537,8 @@ DEFAULTS = {
STRING_OR_NUMBER_ARGS = ['plus2', 'equal2', 'less2', 'greater2', 'box',
'template1x1', 'template1x2', 'template2x1', 'list',
'template2x2', 'template1x1a', 'templatelist', 'nop',
- 'print', 'stack', 'hat', 'addturtle', 'myfunc']
+ 'print', 'stack', 'hat', 'addturtle', 'myfunc',
+ 'myfunc2']
CONTENT_ARGS = ['show', 'showaligned', 'push', 'storein', 'storeinbox1',
'storeinbox2']
diff --git a/talogo.py b/talogo.py
index cb2d86e..da4a8b2 100644
--- a/talogo.py
+++ b/talogo.py
@@ -311,8 +311,9 @@ class LogoCode:
'less?':[2, lambda self,x,y: taless(x,y)],
'minus':[2, lambda self,x,y: taminus(x,y)],
'mod':[2, lambda self,x,y: tamod(x,y)],
- 'myfunc':[1, self.prim_myfunc, True],
- 'myfunction':[2, lambda self, f, x: self.myfunction(f, x)],
+ 'myfunction':[2, lambda self,f,x: self.myfunction(f, [x])],
+ 'myfunction2':[3, lambda self,f,x,y: self.myfunction(f, [x, y])],
+ 'myfunction3':[4, lambda self,f,x,y,z: self.myfunction(f, [x, y, z])],
'nop':[0, lambda self: None],
'nop1':[0, lambda self: None],
'nop2':[0, lambda self: None],
@@ -814,25 +815,8 @@ class LogoCode:
self.ireturn()
yield True
- def prim_myfunc(self, list):
- """
- new_list = [self.intern('myfunction')]
- new_list.append(list)
- # self.icall(self.evline, new_list)
- self.icall(self.eval, new_list)
- yield True
- self.ireturn()
- yield True
- """
- new_list = [self.intern('myfunction')]
- new_list.append(list)
- self.evline(new_list)
- yield True
- self.ireturn()
- yield True
-
def myfunction(self, f, x):
- y = myfunc(f, [x])
+ y = myfunc(f, x)
if y == None:
raise logoerror("#syntaxerror")
stop_logo(self.tw)
diff --git a/tawindow.py b/tawindow.py
index 77ab244..d0115cf 100644
--- a/tawindow.py
+++ b/tawindow.py
@@ -1401,9 +1401,11 @@ class TurtleArtWindow():
if blk.name == 'myfunc2' and n == 4:
blk.spr.labels[1] = 'f(x,y)'
blk.spr.labels[2] = ' '
+ blk.primitive = 'myfunction2'
if blk.name == 'myfunc2' and n == 5:
blk.spr.labels[1] = 'f(x,y,z)'
dy = blk.add_arg(False)
+ blk.primitive = 'myfunction3'
else:
dy = blk.add_arg()
for b in group: