Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #6225
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Back to Basics - IF statements |
| Date | 2016-01-18 15:24 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <n7ivv5$6cq$2@dont-email.me> (permalink) |
| References | <5fb53de5-a057-493f-b58c-5c99572513aa@googlegroups.com> |
On 18/01/16 15:18, mack.altmaniii@gmail.com wrote:
> I started web designing when I was a teen, which at that time web sites were what is now referred to as 'static' in nature. However, I grew with the community and began transitioning from designer to developer to create more 'dynamic' web sites using various various languages I picked up along the way. Although I had my own web design company as a teenager in high school, I pursued a career in accounting while considering my 'tech' skills a hobby. Unfortunately, I was ill-advised by many saying it would never amount to anything. Fastforward a decade, I sit in a position where I use Caché (Mumps) on a daily basis. However, I often question my 'self taught' skills. While I would say I learned them often by tested (time and again) trial and error, I still doubt them.
>
> While I believe this can be answered by any mathematics lover (Who didn't love proofs? Ha!), I want to ask so I stop questioning myself and educate those I'm having to come behind. I feel its a waste of performance, and want to feel confident in saying it is. So here goes.
>
>
> The following is what I am referring to.
>
> if (id = 1) {
> set $piece(^|"app"|global("index"),"^",1)=$horolog
> }
> if (id = 2) {
> set $piece(^|"app"|global("index"),"^",3)=$horolog
> }
> if (id = 3) {
> set $piece(^|"app"|global("index"),"^",5)=$horolog
> }
> if (id = 4) {
> set $piece(^|"app"|global("index"),"^",7)=$horolog
> }
> if (id = 5) {
> set $piece(^|"app"|global("index"),"^",9)=$horolog
> }
>
> I feel each pass through the above wastes performance fivefold.
> The variable (id) is only going to be equal to one of the five
> each time it reaches this point, as it is not changed within
> the if() so why would we verify it hasn't changed when there's
> nothing telling it to change. I feel the above should be written
> as follows. Would anyone write the above in the same way or would
> everyone use the following approach?
>
> if (id = 1) {
> set $piece(^|"app"|global("index"),"^",1)=$horolog
> } elseif (id = 2) {
> set $piece(^|"app"|global("index"),"^",3)=$horolog
> } elseif (id = 3) {
> set $piece(^|"app"|global("index"),"^",5)=$horolog
> } elseif (id = 4) {
> set $piece(^|"app"|global("index"),"^",7)=$horolog
> } elseif (id = 5) {
> set $piece(^|"app"|global("index"),"^",9)=$horolog
> }
set $piece(^|"app"|global("index"),"^",id * 2 - 1) = $horolog
--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Back to Basics - IF statements mack.altmaniii@gmail.com - 2016-01-18 07:18 -0800
Re: Back to Basics - IF statements Richard Heathfield <rjh@cpax.org.uk> - 2016-01-18 15:24 +0000
Re: Back to Basics - IF statements Kaz Kylheku <kaz@kylheku.com> - 2016-01-18 23:29 +0000
Re: Back to Basics - IF statements LinuxNext <nobody@nospam.net> - 2016-01-18 20:34 -0800
Re: Back to Basics - IF statements Richard Heathfield <rjh@cpax.org.uk> - 2016-01-19 07:14 +0000
Re: Back to Basics - IF statements Jim Lee_0 <jlee54@gmail.com> - 2016-01-21 00:44 -0800
Re: Back to Basics - IF statements Öö Tiib <ootiib@hot.ee> - 2016-01-21 08:53 -0800
Re: Back to Basics - IF statements John McCue <jmccue@jmcnet1.bstnma.east.verizon.net> - 2016-01-18 22:26 +0000
Re: Back to Basics - IF statements Richard Heathfield <rjh@cpax.org.uk> - 2016-01-18 22:33 +0000
Re: Back to Basics - IF statements BartC <bc@freeuk.com> - 2016-01-19 13:11 +0000
csiph-web