Re: Keen eyes

2016-01-17 Thread Chris Angelico
On Sun, Jan 17, 2016 at 10:17 PM, BartC wrote: > On 17/01/2016 08:25, Chris Angelico wrote: >> >> On Sun, Jan 17, 2016 at 6:37 PM, Ian Kelly wrote: >>> >>> Technically it defaults to non local. The var statement allocates a >>> variable within the current scope. Otherwise it searches up the chain

Re: Keen eyes

2016-01-17 Thread BartC
On 17/01/2016 08:25, Chris Angelico wrote: On Sun, Jan 17, 2016 at 6:37 PM, Ian Kelly wrote: Technically it defaults to non local. The var statement allocates a variable within the current scope. Otherwise it searches up the chain of parent scopes for a matching variable... This far, it's exa

Re: Keen eyes

2016-01-17 Thread Chris Angelico
On Sun, Jan 17, 2016 at 6:37 PM, Ian Kelly wrote: > Technically it defaults to non local. The var statement allocates a > variable within the current scope. Otherwise it searches up the chain of > parent scopes for a matching variable... This far, it's exactly the same as C. > ... terminating at

Re: Keen eyes

2016-01-16 Thread Paul Rubin
Steven D'Aprano writes: > And this is the language that 95% of the Internet uses... my brain hurts. WAT. https://www.youtube.com/watch?v=20BySC_6HyY -- https://mail.python.org/mailman/listinfo/python-list

Re: Keen eyes

2016-01-16 Thread Ian Kelly
On Jan 17, 2016 12:16 AM, "Steven D'Aprano" wrote: > > On Sun, 17 Jan 2016 10:25 am, jonas.thornv...@gmail.com wrote: > > > double use of j in two different functions > > Are you using a global variable called "j" as a loop variable? That sounds > like a terrible idea. > > You should use local var

Re: Keen eyes

2016-01-16 Thread Steven D'Aprano
On Sun, 17 Jan 2016 10:25 am, jonas.thornv...@gmail.com wrote: > double use of j in two different functions Are you using a global variable called "j" as a loop variable? That sounds like a terrible idea. You should use local variables. Then a function with a local variable j cannot possibly eff

Re: Keen eyes

2016-01-16 Thread jonas . thornvall
Den lördag 16 januari 2016 kl. 23:30:48 UTC+1 skrev Chris Angelico: > On Sun, Jan 17, 2016 at 9:23 AM, wrote: > > function factor_it(i){ > > prime=true; > > sqroot=Math.floor(Math.sqrt(i)); > > for (j=2;j > {return prime}} > > return prime; > > } > > A couple of potential problems here. The firs

Re: Keen eyes

2016-01-16 Thread jonas . thornvall
Den lördag 16 januari 2016 kl. 23:30:48 UTC+1 skrev Chris Angelico: > On Sun, Jan 17, 2016 at 9:23 AM, wrote: > > function factor_it(i){ > > prime=true; > > sqroot=Math.floor(Math.sqrt(i)); > > for (j=2;j > {return prime}} > > return prime; > > } > > A couple of potential problems here. The firs

Re: Keen eyes

2016-01-16 Thread Chris Angelico
On Sun, Jan 17, 2016 at 9:23 AM, wrote: > function factor_it(i){ > prime=true; > sqroot=Math.floor(Math.sqrt(i)); > for (j=2;j prime}} > return prime; > } A couple of potential problems here. The first thing that comes to mind is that floating point inaccuracy is going to bite you long before th