I have pseudo-code like this:
if( b < a)
return (1,0)+foo(a-b,b)
I want to write it in python. But can python add tuples? What is the best way to code something like that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do you want to do element-wise addition, or to append the tuples? By default python does
You could define your own as:
Also, as @delnan’s comment makes it clear, this is better written as
or even more functionally:
Then do