Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32369

Re: Logic problem, i always had problem translate until statements into while

Newsgroups comp.lang.javascript
Date 2017-01-27 02:35 -0800
References (3 earlier) <10dc87b2-3078-4b1d-a914-0461db1c80a6@googlegroups.com> <87sho5zaj9.fsf@bsb.me.uk> <74b7c25f-9f8f-4bc5-8380-9cb6e6e8bd1e@googlegroups.com> <dab5855e-f587-4639-9d5c-11af9a79bdc0@googlegroups.com> <d196cdb5-c79c-4771-bc6a-5fbd2119c437@googlegroups.com>
Message-ID <c7e16efd-38a1-4a5a-b4d2-cb6f91c7dcee@googlegroups.com> (permalink)
Subject Re: Logic problem, i always had problem translate until statements into while
From jonas.thornvall@gmail.com

Show all headers | View raw


Den fredag 27 januari 2017 kl. 11:17:42 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 27 januari 2017 kl. 10:57:26 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 27 januari 2017 kl. 10:33:16 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 27 januari 2017 kl. 00:06:24 UTC+1 skrev Ben Bacarisse:
> > > > jonas.thornvall@gmail.com writes:
> > > > 
> > > > > Den torsdag 26 januari 2017 kl. 22:24:32 UTC+1 skrev jonas.t...@gmail.com:
> > > > >> Den torsdag 26 januari 2017 kl. 21:29:05 UTC+1 skrev Ben Bacarisse:
> > > > >> > jonas.thornvall@gmail.com writes:
> > > > >> > 
> > > > >> > > do until (regular == true && connected == false )
> > > > >> > >
> > > > >> > > I honestly feel a bit lost, because i think they are so easy to code
> > > > >> > > using do until.
> > > > >> > 
> > > > >> > What as the initial values of 'regular' and 'connected'?
> > > > >> > 
> > > > >> > > So how should i think about it?
> > > > >> > 
> > > > >> > Provided the initial value of the resulting while condition is true you
> > > > >> > just need to invert it:
> > > > >> > 
> > > > >> >   while (!(regular == true && connected == false)) ...
> > > > >> > 
> > > > >> > You can use De Morgan's laws to simplify that if you like:
> > > > >> > 
> > > > >> >   !(A && B) <=> !A || !B
> > > > >> >   !(A || B) <=> !A && !B
> > > > >> > 
> > > > >> > in your case
> > > > >> > 
> > > > >> >      !(regular == true && connected == false)
> > > > >> >   => !(regular == true) || !(connected == false) 
> > > > >> >   => regular != true || connected != false
> > > > >> > 
> > > > >> > which I'd just write as
> > > > >> > 
> > > > >> >   while (!regular || connected) ...
> > > > >> > 
> > > > >> > Often, the use of do ... until is simply an error (while is needed more
> > > > >> > often in algorithms than do...until).  In those cases there is no need
> > > > >> > for the loop to execute at least once and you don't need to check that
> > > > >> > '!regular || connected' is initially true.
> > > > >> > 
> > > > >> > -- 
> > > > >> > Ben.
> > > > >> 
> > > > >> Unfortunately they are both false,
> > > > 
> > > > Why is that unfortunate?  If they are both initially false your
> > > > do...until can be written as a while with the condition negated.
> > > > 
> > > > <snip>
> > > > -- 
> > > > Ben.
> > > 
> > > I feel you dodged the obstacle, i asked if the boolean is generated/searched and found within loop and all values of the truth table can be found, how do you set the start condition, can i set the boolean to "null" at start?
> > 
> > I slightly remember one can use a switch within side loop and look for the boolean values within loop and set the switch, but does that not defy the purpose of having booleans in the programming language to start with?
> > 
> > Something either wrong with my way of thinking about it, or there is something wrong with that the boolan value do not have a null configuration. Because i read that in javascript a null setting will return false var x=null, boolean(x) return false?
> > 
> > Maybe it is wrong from a structural point to look at something that have not been generated yet, but it sure would make things alot easier?
> 
> Sometimes the coding get convoluted for what i would call no reason at all.
> Why is programming languages constructed that way, i mean isn't do until clear enough, and why do i need a swithch inside would it be flawed to allow a boolean to be undefined "probably"?
> 
> But it sure would make coding more straight forvard
> 
> NAIVE CODING regular=false connected=false found==false
> 
> if (regbox checked && conbox checked) 
> do until (found==true)
> generate();
> if (regular true && connected true) found true;
> 
> else if (regbox checked && conbox unchecked) 
> do until (found==true)
> generate();
> if (regular true && connected false) found true;
> 
> else if (regbox unchecked && conbox checked) 
> do until (found==true)
> generate();
> if (regular false   && connected true) found true;
> 
> else if (regbox unchecked && connected unchecked)
> do until (found==true)
> generate();
> if (regular false && connected false) found true;

I mean aftarall what is the logic looking for 
while (found==false) or while (found!=true)

compare to 

do until(found==true) elegance ;)

For none programmers i can say that probably 99,999 would express the later as more clearly expressed, so why do programmers prefer the former "negated statement", is it an occupational injury of the programming environment?

It would be like trying to trap a bird, and say as long there is no bird in cage i did not trap any, repeatedly.

While ***normal*** people prefer i do this until i trap a bird "yeah i know they have to check in the box but probably they do check if it is a bird there not if the cage is empty.

So why do programmers look for the empty cage when they want it full, that is my question.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-26 10:39 -0800
  Re: Logic problem, i always had problem translate until statements into while Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-26 20:28 +0000
    Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-26 13:24 -0800
      Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-26 13:33 -0800
        Re: Logic problem, i always had problem translate until statements into while Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-26 23:06 +0000
          Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 01:33 -0800
            Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 01:57 -0800
              Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 02:17 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 02:35 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 02:39 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 02:43 -0800
                Re: Logic problem, i always had problem translate until statements into while Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-27 11:23 +0000
                Re: Logic problem, i always had problem translate until statements into while Tim Streater <timstreater@greenbee.net> - 2017-01-27 12:14 +0000
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 08:00 -0800
                Re: Logic problem, i always had problem translate until statements into while Gene Wirchenko <genew@telus.net> - 2017-01-27 09:29 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 10:43 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 10:44 -0800
                Re: Logic problem, i always had problem translate until statements into while Gene Wirchenko <genew@telus.net> - 2017-01-27 15:46 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 18:20 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 18:34 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 18:51 -0800
                Re: Logic problem, i always had problem translate until statements into while John Harris <niam@jghnorth.org.uk.invalid> - 2017-01-28 10:07 +0000
                Re: Logic problem, i always had problem translate until statements into while Gene Wirchenko <genew@telus.net> - 2017-01-30 09:14 -0800
                Re: Logic problem, i always had problem translate until statements into while "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-28 10:48 +0100
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-28 05:05 -0800
                Re: Logic problem, i always had problem translate until statements into while "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-27 13:43 +0100
                Re: Logic problem, i always had problem translate until statements into while Scott Sauyet <scott.sauyet@gmail.com> - 2017-01-27 19:52 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 22:25 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 22:36 -0800
                Re: Logic problem, i always had problem translate until statements into while Scott Sauyet <scott.sauyet@gmail.com> - 2017-01-29 18:05 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-30 09:25 -0800
                Re: Logic problem, i always had problem translate until statements into while Dr J R Stockton <reply1700@merlyn.demon.co.uk.invalid> - 2017-01-31 23:12 +0000
                Re: Logic problem, i always had problem translate until statements into while "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-01 09:22 +0100
            Re: Logic problem, i always had problem translate until statements into while Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-27 11:02 +0000
              Re: Logic problem, i always had problem translate until statements into while Tim Streater <timstreater@greenbee.net> - 2017-01-27 12:11 +0000
              Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 07:53 -0800
                Re: Logic problem, i always had problem translate until statements into while "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-27 17:07 +0100
                Re: Logic problem, i always had problem translate until statements into while Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-28 00:55 +0000
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 18:14 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-27 18:15 -0800
                Re: Logic problem, i always had problem translate until statements into while Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-28 15:22 +0000
                Re: Logic problem, i always had problem translate until statements into while Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-28 16:54 +0100
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-28 13:53 -0800
                Re: Logic problem, i always had problem translate until statements into while Tim Streater <timstreater@greenbee.net> - 2017-01-28 22:13 +0000
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-29 01:27 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-01-29 09:41 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-02-01 08:51 -0800
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-02-01 09:03 -0800
                Re: Logic problem, i always had problem translate until statements into while "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-01 19:19 +0100
                Re: Logic problem, i always had problem translate until statements into while Tim Streater <timstreater@greenbee.net> - 2017-02-01 18:35 +0000
                Re: Logic problem, i always had problem translate until statements into while "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-02-01 19:40 +0100
                Re: Logic problem, i always had problem translate until statements into while Tim Streater <timstreater@greenbee.net> - 2017-02-01 19:06 +0000
                Re: Logic problem, i always had problem translate until statements into while Tim Streater <timstreater@greenbee.net> - 2017-02-01 19:09 +0000
                Re: Logic problem, i always had problem translate until statements into while jonas.thornvall@gmail.com - 2017-02-01 08:51 -0800
                Re: Logic problem, i always had problem translate until statements into while Tim Streater <timstreater@greenbee.net> - 2017-02-01 16:56 +0000
            Re: Logic problem, i always had problem translate until statements into while "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-27 13:36 +0100

csiph-web