Re: Understanding how is a function evaluated using recursion

2013-09-29 Thread rusi
On Thursday, September 26, 2013 4:54:22 AM UTC+5:30, Arturo B wrote: So I know what recursion is, but I don't know how is flatten(i) evaluated, what value does it returns? There is a folklore in CS that recursion is hard [To iterate is human, to recurse divine --

Re: Understanding how is a function evaluated using recursion

2013-09-28 Thread Peter Cacioppi
On Thursday, September 26, 2013 7:23:47 AM UTC-7, Neil Cerutti wrote: On 2013-09-26, Neil Cerutti ne...@norwich.edu wrote: def flatten(seq): [1] http://en.wiktionary.org/wiki/bikeshed In that spirit, it occurs to me that given current Python nomenclature, 'flattened' would

Re: Understanding how is a function evaluated using recursion

2013-09-26 Thread Neil Cerutti
On 2013-09-25, Arturo B a7xrturo...@gmail.com wrote: Hi, I'm doing Python exercises and I need to write a function to flat nested lists as this one: [[1,2,3],4,5,[6,[7,8]]] To the result: [1,2,3,4,5,6,7,8] So I searched for example code and I found this one that uses recursion (that I

Re: Understanding how is a function evaluated using recursion

2013-09-26 Thread Neil Cerutti
On 2013-09-26, Neil Cerutti ne...@norwich.edu wrote: def flatten(seq): [1] http://en.wiktionary.org/wiki/bikeshed In that spirit, it occurs to me that given current Python nomenclature, 'flattened' would be a better name. -- Neil Cerutti --

Understanding how is a function evaluated using recursion

2013-09-25 Thread Arturo B
Hi, I'm doing Python exercises and I need to write a function to flat nested lists as this one: [[1,2,3],4,5,[6,[7,8]]] To the result: [1,2,3,4,5,6,7,8] So I searched for example code and I found this one that uses recursion (that I don't understand): def flatten(l): ret = [] for i

Re: Understanding how is a function evaluated using recursion

2013-09-25 Thread Josh English
On Wednesday, September 25, 2013 4:24:22 PM UTC-7, Arturo B wrote: Hi, I'm doing Python exercises and I need to write a function to flat nested lists So I know what recursion is, but I don't know how is flatten(i) evaluated, what value does it returns? In

Re: Understanding how is a function evaluated using recursion

2013-09-25 Thread MRAB
On 26/09/2013 00:24, Arturo B wrote: Hi, I'm doing Python exercises and I need to write a function to flat nested lists as this one: [[1,2,3],4,5,[6,[7,8]]] To the result: [1,2,3,4,5,6,7,8] So I searched for example code and I found this one that uses recursion (that I don't understand):

Re: Understanding how is a function evaluated using recursion

2013-09-25 Thread Steven D'Aprano
On Wed, 25 Sep 2013 16:24:22 -0700, Arturo B wrote: Hi, I'm doing Python exercises and I need to write a function to flat nested lists as this one: [[1,2,3],4,5,[6,[7,8]]] To the result: [1,2,3,4,5,6,7,8] So I searched for example code and I found this one that uses recursion (that

Re: Understanding how is a function evaluated using recursion

2013-09-25 Thread Dave Angel
On 25/9/2013 19:24, Arturo B wrote: Hi, I'm doing Python exercises and I need to write a function to flat nested lists as this one: [[1,2,3],4,5,[6,[7,8]]] To the result: [1,2,3,4,5,6,7,8] So I searched for example code and I found this one that uses recursion (that I don't

Re: Understanding how is a function evaluated using recursion

2013-09-25 Thread Terry Reedy
On 9/25/2013 7:24 PM, Arturo B wrote: Hi, I'm doing Python exercises and I need to write a function to flat nested lists as this one: [[1,2,3],4,5,[6,[7,8]]] To the result: [1,2,3,4,5,6,7,8] So I searched for example code and I found this one that uses recursion (that I don't understand):

Re: Understanding how is a function evaluated using recursion

2013-09-25 Thread rusi
On Thursday, September 26, 2013 4:54:22 AM UTC+5:30, Arturo B wrote: So I know what recursion is, but I don't know how is flatten(i) evaluated, what value does it returns? When you are a noob, who do you ask? The gurus. When you are a guru who do you ask? The