| 648 | |
| 649 | @scope.define |
| 650 | def partial(name, *args, **kwargs): |
| 651 | # TODO: introspect the named instruction, to retrieve the |
| 652 | # list of parameters *not* accounted for by args and kwargs |
| 653 | # then delete these stupid functions and just have one `partial` |
| 654 | try: |
| 655 | name = name.apply_name # to retrieve name from scope.foo methods |
| 656 | except AttributeError: |
| 657 | pass |
| 658 | |
| 659 | my_id = len(scope._impls) |
| 660 | # -- create a function with this name |
| 661 | # the name is the string used index into scope._impls |
| 662 | temp_name = "partial_%s_id%i" % (name, my_id) |
| 663 | l = Lambda(temp_name, [("x", p0)], expr=apply(name, *(args + (p0,)), **kwargs)) |
| 664 | scope.define(l) |
| 665 | # assert that the next partial will get a different id |
| 666 | # XXX; THIS ASSUMES THAT SCOPE ONLY GROWS |
| 667 | assert my_id < len(scope._impls) |
| 668 | rval = getattr(scope, temp_name) |
| 669 | return rval |
| 670 | |
| 671 | |
| 672 | def dfs(aa, seq=None, seqset=None): |