Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is copy or reference in self recursion? #137

Closed
daidai21 opened this issue Sep 9, 2019 · 1 comment
Closed

Is copy or reference in self recursion? #137

daidai21 opened this issue Sep 9, 2019 · 1 comment
Assignees
Milestone

Comments

@daidai21
Copy link

daidai21 commented Sep 9, 2019

Hello, I not found in this repository about this grammar. so, I open this issue.
My CPython version is 3.7.1

  • list recursion (reference )
class C:
    def f1(self, a):
        if a[0][0] == 0:
            return a
        else:
            a[0][0] -= 1

        self.f1(a)
        return a


print(C().f1([[5, 2],[3, 4]]))

result:

>>> [[0, 2], [3, 4]]
  • variable recursion (copy)
class C:
    def f1(self, a):
        if a == 0:
            return a
        else:
            a -= 1

        self.f1(a)
        return a


print(C().f1(3))

result

>>> 2

Just defining functions is the same.
Thank you.

@satwikkansal satwikkansal added this to the 3.0 milestone Sep 10, 2019
@satwikkansal
Copy link
Owner

Great, thanks for suggesting this @daidai21

Will definitely add this in the next iteration.

@satwikkansal satwikkansal self-assigned this Oct 29, 2019
muscliary pushed a commit to muscliary/wtfpython that referenced this issue Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants