Re: [U2] Simplify, or why mathematicians make better programmers
On 16/11/11 16:18, Jacques G. wrote: Why does your example have : Real which is a type found in languages of the Pascal family such as: Pascal, Modula2 and possibly Delphi . (Considered obsolete in Delphi) :-) btw, I've never programmed in a Pascal-like language, despite having a go at Modula-2 ages ago... in a program which uses C family syntax ? C++, C#, Java none of which have the Real type. Maybe it's because I cut my teeth on Fortran? And I haven't programmed in anger in C for a while. Anyways, I did say "something like" - I'm remembering back to some time in the mid-90s. Cheers, Wol From: Wols Lists To: u2-users@listserver.u2ug.org Sent: Monday, November 14, 2011 4:44 PM Subject: Re: [U2] Simplify, or why mathematicians make better programmers On 14/11/11 19:49, George Gallen wrote: Or didn't know about the INT() command, and forced everything to be even. Which in reality, is kinda odd. (Couldn't resist). :-) In reality, you could well be correct !!! When I was involved in recruiting a C programmer ages ago, we set a simple competence test. I lifted a snippet of code from one of OUR OWN programs somewhere that said something like ... real rr = our value of interest; int ii = rr*10; int mm = ( rr - (float(ii)/10) ) * 10; if (mm>5) float rr2 = int( rr + .5 ); else float rr2 = int( rr); We asked the candidates to identify what this code was doing, and could they do it any simpler. We made a point of saying that all we wanted was for them to spot what was going on ... With only ONE exception, every candidate rewrote it and made it even more convoluted. That one exception got it right ... rr2 = round( rr); Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Simplify, or why mathematicians make better programmers
Why does your example have : Real which is a type found in languages of the Pascal family such as: Pascal, Modula2 and possibly Delphi . (Considered obsolete in Delphi) in a program which uses C family syntax ? C++, C#, Java none of which have the Real type. From: Wols Lists To: u2-users@listserver.u2ug.org Sent: Monday, November 14, 2011 4:44 PM Subject: Re: [U2] Simplify, or why mathematicians make better programmers On 14/11/11 19:49, George Gallen wrote: > Or didn't know about the INT() command, and forced everything to be even. > > Which in reality, is kinda odd. (Couldn't resist). > :-) In reality, you could well be correct !!! When I was involved in recruiting a C programmer ages ago, we set a simple competence test. I lifted a snippet of code from one of OUR OWN programs somewhere that said something like ... real rr = our value of interest; int ii = rr*10; int mm = ( rr - (float(ii)/10) ) * 10; if (mm>5) float rr2 = int( rr + .5 ); else float rr2 = int( rr); We asked the candidates to identify what this code was doing, and could they do it any simpler. We made a point of saying that all we wanted was for them to spot what was going on ... With only ONE exception, every candidate rewrote it and made it even more convoluted. That one exception got it right ... rr2 = round( rr); Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Simplify, or why mathematicians make better programmers
On 14/11/11 19:49, George Gallen wrote: Or didn't know about the INT() command, and forced everything to be even. Which in reality, is kinda odd. (Couldn't resist). :-) In reality, you could well be correct !!! When I was involved in recruiting a C programmer ages ago, we set a simple competence test. I lifted a snippet of code from one of OUR OWN programs somewhere that said something like ... real rr = our value of interest; int ii = rr*10; int mm = ( rr - (float(ii)/10) ) * 10; if (mm>5) float rr2 = int( rr + .5 ); else float rr2 = int( rr); We asked the candidates to identify what this code was doing, and could they do it any simpler. We made a point of saying that all we wanted was for them to spot what was going on ... With only ONE exception, every candidate rewrote it and made it even more convoluted. That one exception got it right ... rr2 = round( rr); Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Simplify, or why mathematicians make better programmers
Or didn't know about the INT() command, and forced everything to be even. Which in reality, is kinda odd. (Couldn't resist). -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, November 14, 2011 2:48 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Simplify, or why mathematicians make better programmers Right in my snippet it's just 40-Len(x) But the original programmer couldn't see that deeply. -Original Message- From: George Gallen To: U2 Users List Sent: Mon, Nov 14, 2011 11:43 am Subject: Re: [U2] Simplify, or why mathematicians make better programmers Actually, the INT wouldn't be needed. I'm guessing that the +1 was to make the 79 even nything*2 will be even So and even# (80) - and even# (*2) / 2 will always be even , no int needed. -Original Message- rom: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] n Behalf Of Charlie Noah ent: Monday, November 14, 2011 2:41 PM o: U2 Users List ubject: Re: [U2] Simplify, or why mathematicians make better programmers Actually, it needs more than simplification - the result it returns is lose, but not exactly right. I use OL = INT((79 - LEN(SITE.NAME)) / 2), which, if LEN(SITE.NAME) = 10, is 4. The exact position would be 34.5, but that half a column is tough to o (hence the INT). The original code snippet returned 30. Charlie On 11-14-2011 1:19 PM, George Gallen wrote: I'm guessing it started out simpler, and extra steps were added to make lignment corrections, And nobody bothered to simplify. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] n Behalf Of Wjhonson Sent: Monday, November 14, 2011 1:59 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Simplify, or why mathematicians make better programmers COL = (79-LEN(SITE.NAME)*2+1)/2 Is it just me, or are there people out there who really don't get math ? ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users __ 2-Users mailing list 2-us...@listserver.u2ug.org ttp://listserver.u2ug.org/mailman/listinfo/u2-users __ 2-Users mailing list 2-us...@listserver.u2ug.org ttp://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Simplify, or why mathematicians make better programmers
Right in my snippet it's just 40-Len(x) But the original programmer couldn't see that deeply. -Original Message- From: George Gallen To: U2 Users List Sent: Mon, Nov 14, 2011 11:43 am Subject: Re: [U2] Simplify, or why mathematicians make better programmers Actually, the INT wouldn't be needed. I'm guessing that the +1 was to make the 79 even nything*2 will be even So and even# (80) - and even# (*2) / 2 will always be even , no int needed. -Original Message- rom: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] n Behalf Of Charlie Noah ent: Monday, November 14, 2011 2:41 PM o: U2 Users List ubject: Re: [U2] Simplify, or why mathematicians make better programmers Actually, it needs more than simplification - the result it returns is lose, but not exactly right. I use OL = INT((79 - LEN(SITE.NAME)) / 2), which, if LEN(SITE.NAME) = 10, is 4. The exact position would be 34.5, but that half a column is tough to o (hence the INT). The original code snippet returned 30. Charlie On 11-14-2011 1:19 PM, George Gallen wrote: I'm guessing it started out simpler, and extra steps were added to make lignment corrections, And nobody bothered to simplify. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] n Behalf Of Wjhonson Sent: Monday, November 14, 2011 1:59 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Simplify, or why mathematicians make better programmers COL = (79-LEN(SITE.NAME)*2+1)/2 Is it just me, or are there people out there who really don't get math ? ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users __ 2-Users mailing list 2-us...@listserver.u2ug.org ttp://listserver.u2ug.org/mailman/listinfo/u2-users __ 2-Users mailing list 2-us...@listserver.u2ug.org ttp://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Simplify, or why mathematicians make better programmers
Actually, the INT wouldn't be needed. I'm guessing that the +1 was to make the 79 even Anything*2 will be even So and even# (80) - and even# (*2) / 2 will always be even , no int needed. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Charlie Noah Sent: Monday, November 14, 2011 2:41 PM To: U2 Users List Subject: Re: [U2] Simplify, or why mathematicians make better programmers Actually, it needs more than simplification - the result it returns is close, but not exactly right. I use COL = INT((79 - LEN(SITE.NAME)) / 2), which, if LEN(SITE.NAME) = 10, is 34. The exact position would be 34.5, but that half a column is tough to do (hence the INT). The original code snippet returned 30. Charlie On 11-14-2011 1:19 PM, George Gallen wrote: > I'm guessing it started out simpler, and extra steps were added to make > alignment corrections, > And nobody bothered to simplify. > > -Original Message- > From: u2-users-boun...@listserver.u2ug.org > [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson > Sent: Monday, November 14, 2011 1:59 PM > To: u2-users@listserver.u2ug.org > Subject: Re: [U2] Simplify, or why mathematicians make better programmers > > > COL = (79-LEN(SITE.NAME)*2+1)/2 > > Is it just me, or are there people out there who really don't get math ? > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Simplify, or why mathematicians make better programmers
Actually, it needs more than simplification - the result it returns is close, but not exactly right. I use COL = INT((79 - LEN(SITE.NAME)) / 2), which, if LEN(SITE.NAME) = 10, is 34. The exact position would be 34.5, but that half a column is tough to do (hence the INT). The original code snippet returned 30. Charlie On 11-14-2011 1:19 PM, George Gallen wrote: I'm guessing it started out simpler, and extra steps were added to make alignment corrections, And nobody bothered to simplify. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, November 14, 2011 1:59 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Simplify, or why mathematicians make better programmers COL = (79-LEN(SITE.NAME)*2+1)/2 Is it just me, or are there people out there who really don't get math ? ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Simplify, or why mathematicians make better programmers
I'm guessing it started out simpler, and extra steps were added to make alignment corrections, And nobody bothered to simplify. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, November 14, 2011 1:59 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Simplify, or why mathematicians make better programmers COL = (79-LEN(SITE.NAME)*2+1)/2 Is it just me, or are there people out there who really don't get math ? ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Simplify, or why mathematicians make better programmers
COL = (79-LEN(SITE.NAME)*2+1)/2 Is it just me, or are there people out there who really don't get math ? ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users