spielwiese
Last change
on this file since 68549d was
68549d,
checked in by Michael Brickenstein <bricken@…>, 18 years ago
|
*bricken: initial version
git-svn-id: file:///usr/local/Singular/svn/trunk@8358 2c84dea3-7e68-4137-9b89-c4e89433aadc
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | from objects import OMobject, OMsymbol |
---|
2 | from cd import * |
---|
3 | from omexceptions import * |
---|
4 | from itertools import izip |
---|
5 | cdFns1=OMcd("fns1") |
---|
6 | lambdasym=OMsymbol("lambda",cdFns1) |
---|
7 | |
---|
8 | def islambda(sym): |
---|
9 | return lambdasym==sym |
---|
10 | |
---|
11 | class OMbinding(OMobject): |
---|
12 | def __init__(self, binder,variables,block): |
---|
13 | super(OMbinding,self).__init__() |
---|
14 | self.block=block |
---|
15 | self.binder=binder |
---|
16 | self.variables=variables |
---|
17 | def evaluate(self,context): |
---|
18 | assert islambda(self.binder) |
---|
19 | self.scope=context.scopeFromCurrentScope() |
---|
20 | return self |
---|
21 | def bind(self, args): |
---|
22 | #print args, self.variables |
---|
23 | assert len(args)==len(self.variables) |
---|
24 | varBindings=dict(izip([i.name for i in self.variables],args)) |
---|
25 | self.scope.push(varBindings) |
---|
26 | def unbind(self): |
---|
27 | self.scope.pop() |
---|
28 | |
---|
29 | def calcErg(self,context): |
---|
30 | return context.evaluateInScope(self.block,self.scope) |
---|
31 | def __call__(self, context,*args): |
---|
32 | self.bind(args) |
---|
33 | erg=self.calcErg(context) |
---|
34 | self.unbind() |
---|
35 | #print "__call__ erg is", erg |
---|
36 | return erg |
---|
37 | |
---|
Note: See
TracBrowser
for help on using the repository browser.