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


Groups > comp.lang.javascript > #37337 > unrolled thread

A proposition for a conditional loop.

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2019-09-23 00:55 -0700
Last post2019-09-25 17:07 +0200
Articles 20 on this page of 54 — 6 participants

Back to article view | Back to comp.lang.javascript


Contents

  A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-23 00:55 -0700
    Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-23 01:05 -0700
      Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-23 01:14 -0700
        Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-23 01:16 -0700
          Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-24 05:12 -0700
    Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-24 22:27 +0200
      Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-24 22:39 -0700
        Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-25 09:05 +0200
          Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 02:47 -0700
            Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-25 13:13 +0200
              Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 05:13 -0700
                Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-25 15:04 +0200
                  Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 06:10 -0700
                    Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-25 15:50 +0100
                      Re: A proposition for a conditional loop. Tim Streater <timstreater@greenbee.net> - 2019-09-25 16:00 +0100
                      Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 10:20 -0700
                        Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 10:26 -0700
                          Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-25 19:18 +0100
                            Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-25 12:19 -0700
                              Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-26 10:48 +0100
                                Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-26 04:38 -0700
                                  Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-26 18:05 +0100
                                    Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-26 10:54 -0700
                                      Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-27 10:06 +0100
                                        Re: A proposition for a conditional loop. dr.j.r.stockton@gmail.com - 2019-09-27 02:34 -0700
                                        Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 05:32 -0700
                                          Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 05:36 -0700
                                            Re: A proposition for a conditional loop. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-09-27 20:23 +0100
                                              Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 12:45 -0700
                                                Re: A proposition for a conditional loop. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-09-27 22:05 +0100
                                                  Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 14:39 -0700
                                                    Re: A proposition for a conditional loop. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-09-28 00:16 +0100
                                                      Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 17:10 -0700
                                                        Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-28 17:28 +0200
                                                          Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-28 11:34 -0700
                                                            Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-28 22:23 +0200
                                                              Re: A proposition for a conditional loop. Tim Streater <timstreater@greenbee.net> - 2019-09-28 21:42 +0100
                                                              Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-29 07:40 -0700
                                                                Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-29 18:33 +0200
                                                                  Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-29 09:58 -0700
                                                                    Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-29 19:18 +0100
                                                                    Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-29 21:02 +0200
                                                                      Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-29 13:54 -0700
                                                  Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-28 10:41 +0100
                                              Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 13:17 -0700
                                          Re: A proposition for a conditional loop. Tim Streater <timstreater@greenbee.net> - 2019-09-27 13:41 +0100
                                          Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 06:01 -0700
                                            Re: A proposition for a conditional loop. Tim Streater <timstreater@greenbee.net> - 2019-09-27 14:03 +0100
                                          Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-27 19:23 +0100
                                            Re: A proposition for a conditional loop. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-27 12:06 -0700
                                              Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-28 14:43 +0100
                            Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-25 21:47 +0100
                              Re: A proposition for a conditional loop. John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-26 10:49 +0100
                    Re: A proposition for a conditional loop. "R.Wieser" <address@not.available> - 2019-09-25 17:07 +0200

Page 1 of 3  [1] 2 3  Next page →


#37337 — A proposition for a conditional loop.

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-23 00:55 -0700
SubjectA proposition for a conditional loop.
Message-ID<59bee1c7-4afe-445e-8f73-b3248e75040c@googlegroups.com>
Well this or similar, is probably implemented in some language or  possible done with while and multi conditions?

But instead of for loops and if clause inside with a break.

Why not do....

step=1;
x="something"
do until (this equal that) { inc x, step}
then do { whatever }

First off no break needed, no separate conditioning from loop?

        

[toc] | [next] | [standalone]


#37338

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-23 01:05 -0700
Message-ID<140f2d37-4682-433d-91a3-d94ed04e2890@googlegroups.com>
In reply to#37337
Den måndag 23 september 2019 kl. 09:55:31 UTC+2 skrev Jonas Thörnvall:
> Well this or similar, is probably implemented in some language or  possible done with while and multi conditions?
> 
> But instead of for loops and if clause inside with a break.
> 
> Why not do....
> 
> step=1;
> x="something"
> do until (this equal that) { inc x, step}
> then do { whatever }
> 
> First off no break needed, no separate conditioning from loop?

Well maybe (this equal that[x]) would been clearer.

[toc] | [prev] | [next] | [standalone]


#37339

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-23 01:14 -0700
Message-ID<37dacf12-6401-4d3f-944a-2df28b79a53b@googlegroups.com>
In reply to#37338
Den måndag 23 september 2019 kl. 10:06:00 UTC+2 skrev Jonas Thörnvall:
> Den måndag 23 september 2019 kl. 09:55:31 UTC+2 skrev Jonas Thörnvall:
> > Well this or similar, is probably implemented in some language or  possible done with while and multi conditions?
> > 
> > But instead of for loops and if clause inside with a break.
> > 
> > Why not do....
> > 
> > step=1;
> > x="something"
> > do until (this equal that) { inc x, step}
> > then do { whatever }
> > 
> > First off no break needed, no separate conditioning from loop?
> 
> Well maybe (this equal that[x]) would been clearer.

I can see it is prone to infinite loops but so is while also.

I mean doing this with while just not possible it will be a weird statement.

while (this != that[x]){
x++;
]

whatever

It is basicly same thing, but does not feel right. Somehow the connection between what is going on in loop and why is lost to the thing "whatever" you want to do.

[toc] | [prev] | [next] | [standalone]


#37340

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-23 01:16 -0700
Message-ID<5aec3f2e-f0e5-4167-9fb5-042c32a5e6f5@googlegroups.com>
In reply to#37339
Den måndag 23 september 2019 kl. 10:14:05 UTC+2 skrev Jonas Thörnvall:
> Den måndag 23 september 2019 kl. 10:06:00 UTC+2 skrev Jonas Thörnvall:
> > Den måndag 23 september 2019 kl. 09:55:31 UTC+2 skrev Jonas Thörnvall:
> > > Well this or similar, is probably implemented in some language or  possible done with while and multi conditions?
> > > 
> > > But instead of for loops and if clause inside with a break.
> > > 
> > > Why not do....
> > > 
> > > step=1;
> > > x="something"
> > > do until (this equal that) { inc x, step}
> > > then do { whatever }
> > > 
> > > First off no break needed, no separate conditioning from loop?
> > 
> > Well maybe (this equal that[x]) would been clearer.
> 
> I can see it is prone to infinite loops but so is while also.
> 
> I mean doing this with while just not possible it will be a weird statement.
> 
> while (this != that[x]){
> x++;
> ]
> 
> whatever
> 
> It is basicly same thing, but does not feel right. Somehow the connection between what is going on in loop and why is lost to the thing "whatever" you want to do.

I think the connection between syntax to semantics get lost.

[toc] | [prev] | [next] | [standalone]


#37356

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-24 05:12 -0700
Message-ID<13b44d81-bfaf-4736-9ddc-16875b60d2d6@googlegroups.com>
In reply to#37340
Den måndag 23 september 2019 kl. 10:16:12 UTC+2 skrev Jonas Thörnvall:
> Den måndag 23 september 2019 kl. 10:14:05 UTC+2 skrev Jonas Thörnvall:
> > Den måndag 23 september 2019 kl. 10:06:00 UTC+2 skrev Jonas Thörnvall:
> > > Den måndag 23 september 2019 kl. 09:55:31 UTC+2 skrev Jonas Thörnvall:
> > > > Well this or similar, is probably implemented in some language or  possible done with while and multi conditions?
> > > > 
> > > > But instead of for loops and if clause inside with a break.
> > > > 
> > > > Why not do....
> > > > 
> > > > step=1;
> > > > x="something"
> > > > do until (this equal that) { inc x, step}
> > > > then do { whatever }
> > > > 
> > > > First off no break needed, no separate conditioning from loop?
> > > 
> > > Well maybe (this equal that[x]) would been clearer.
> > 
> > I can see it is prone to infinite loops but so is while also.
> > 
> > I mean doing this with while just not possible it will be a weird statement.
> > 
> > while (this != that[x]){
> > x++;
> > ]
> > 
> > whatever
> > 
> > It is basicly same thing, but does not feel right. Somehow the connection between what is going on in loop and why is lost to the thing "whatever" you want to do.
> 
> I think the connection between syntax to semantics get lost.

https://techdocs.broadcom.com/content/dam/broadcom/techdocs/us/en/assets/docops/caet/923525.png

[toc] | [prev] | [next] | [standalone]


#37370

From"R.Wieser" <address@not.available>
Date2019-09-24 22:27 +0200
Message-ID<qmdu75$1vo0$1@gioia.aioe.org>
In reply to#37337
Jonas,

> Why not do....
>
> step=1;
> x="something"
> do until (this equal that) { inc x, step}
> then do { whatever }

Because that is not valid javascript ?

> I mean doing this with while just not possible it will be a weird 
> statement.
>
> while (this != that[x]){
> x++;
> ]

And thats not valid javascript either.   Both also create a problem : What 
are the non-js parts (like "{ inc x, step}" or "that[x]) actually supposed 
to mean ?    I can /guess/, but I should not be forced to do that ...

In short: When posting examples its a good idea to use a /working/ one.  It 
makes it much easier to understand.

Like this:

x=0
while (x <5) {
 ..
 ..
  // do stuf
 ..
 ..
  x += 2
}

And yes, that works.

Now ask yourself: What /good/ does it do to smear a "for" loop out over 
three seperate lines, with the incrementing of the loopcounter being as far 
away from its initialisation & checking as possible ?

Compare it with a "for" loop:

for (x=0; x<5; x += 2 {
 ..
 ..
  // do stuf
 ..
 ..
}

Here everything that matters to the loop is close together - on a single 
line even - , making it much harder  to make a "what was the loopcounter 
variable and by how much should it advance again ?" mistakes.

But, bottom line: use the loop you like best, as it doesn't really matter to 
the code itself. (below the surface the "for", "while", "do while" and "do 
until" loops work exactly the same).

Regards,
Rudy Wieser

[toc] | [prev] | [next] | [standalone]


#37373

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-24 22:39 -0700
Message-ID<58927a8f-1d2c-40fe-b198-e7ecb586d141@googlegroups.com>
In reply to#37370
Den tisdag 24 september 2019 kl. 22:27:25 UTC+2 skrev R.Wieser:
> Jonas,
> 
> > Why not do....
> >
> > step=1;
> > x="something"
> > do until (this equal that) { inc x, step}
> > then do { whatever }
> 
> Because that is not valid javascript ?
> 
> > I mean doing this with while just not possible it will be a weird 
> > statement.
> >
> > while (this != that[x]){
> > x++;
> > ]
> 
> And thats not valid javascript either.   Both also create a problem : What 
> are the non-js parts (like "{ inc x, step}" or "that[x]) actually supposed 
> to mean ?    I can /guess/, but I should not be forced to do that ...
> 
> In short: When posting examples its a good idea to use a /working/ one.  It 
> makes it much easier to understand.
> 
> Like this:
> 
> x=0
> while (x <5) {
>  ..
>  ..
>   // do stuf
>  ..
>  ..
>   x += 2
> }
> 
> And yes, that works.
> 
> Now ask yourself: What /good/ does it do to smear a "for" loop out over 
> three seperate lines, with the incrementing of the loopcounter being as far 
> away from its initialisation & checking as possible ?
> 
> Compare it with a "for" loop:
> 
> for (x=0; x<5; x += 2 {
>  ..
>  ..
>   // do stuf
>  ..
>  ..
> }
> 
> Here everything that matters to the loop is close together - on a single 
> line even - , making it much harder  to make a "what was the loopcounter 
> variable and by how much should it advance again ?" mistakes.
> 
> But, bottom line: use the loop you like best, as it doesn't really matter to 
> the code itself. (below the surface the "for", "while", "do while" and "do 
> until" loops work exactly the same).
> 
> Regards,
> Rudy Wieser

I think you missed the point Rudy, did you check the picture i posted?

There is actually two types of loops, there it "do while" and "do until" loops, i just state that the "do until" does not have a satisfactionary semantics either with for or while. 

Because you will have to use negations until your condition is satisfied, and **after** loop finished do what you try to achieve.
Thus it ends up.

while (this!=that[x]){
x++;
}
do_It();

This is not a satisfying semantics.

or if you use for

for (x=0;x<that.length;x++) {
if (this==that[x]){
do_It();
break
}
}

A child see that ain't a good way to do it, you break up the statement, and have to use a break to not loop unnecessary.

Now compare to this BASIC approach, with an extra then to encapsulate the codpiece to a single unit. 

step=1;
x="something"
do until (this==that[x]) { inc x, step}
then do { doIt(); }

Yeah i know i am a genius, but it does not take a genius to see which approach have the correct semantics, just common sense. Something alot of ENTP lacks.

Well i am well aware about it is not Javascript syntax, i just told you a  more correct semantics for the javascript syntax.

I mean your example does not even make sense, it is not do until, your example is do while.

So... I am just here to complain, but my complaints do make sense.

[toc] | [prev] | [next] | [standalone]


#37374

From"R.Wieser" <address@not.available>
Date2019-09-25 09:05 +0200
Message-ID<qmf3jo$11dm$1@gioia.aioe.org>
In reply to#37373
Jonas,

> I think you missed the point Rudy, did you check the picture i posted?

Noipe, I didn't.   And no, I did not check the picture either.  Phew: A Do
while and a Do until loop.  Shocking.   Not explaining anything, one way or
another. :-(

I /assumed/ that this thread was about the "for" loop.  And pardon me, but
looking at the rest of your messages (no "do until" form of the "for" loop)
it looks like I'm right.   Than again,. you did not actually say that, so
there still is a possibility I'm wrong on that.

> Because you will have to use negations until your condition is
> satisfied, and **after** loop finished do what you try to achieve.
> Thus it ends up.
>
> while (this!=that[x]){
> x++;
> }
> do_It();

I'm sorry, but the above sentence and "code" are gibberish to me.  "use
negations" ?   Like "a = -a" ?  Something else perhaps ?   And "your
condition" ?   Where ?   What condition ?  That "this!=that[x]" part ?
Whats wrong with it (other than it being non-valid ....)  ?  Though that
condition does not show any kind of "negation", so I'm not even sure you are
referring to it.  But if not, what /are/ you there referring to ?

In short: Rephrase please.   What is that condition you want to see, and
what role should that negation play in it.

And to be blunt about it: Your initial post in this thread is sorely lacking
too : It definitily does /not/ specify what you are after. Yes, a I saw that
you wanted a conditional loop.  The problem is that you included /zero/
information to what that loop should do, or how it differs from the multiple
ones we already got. :-(

Bottom line: When writing something (especially a thread-starter) /think/
about what you want to tell/ask us.  And than write it as if we, the
readers, do /not/ have any mind-reading capabilities (meaning: if you do not
say it we do not know it).   Specify /why/ you posted.

And yes, that often means you start with a centence *outlining the
problem/idea/whatever*.  Starting a thread (or even post) with "Well this or
similar" /when you have not actually said anything/ (there is no "this" yet)
does not make any sense I'm afraid.



But after having read the whole it boils down to that there is no "do until"
form of the "for" loop.  Correct ?

In that case, why didn't you just /say so/ and ask ?  Or google for it ?

for (i=5, flag=true ; i<2 || flag ; i++, flag=false) {
    // do something
}

Presto, a "for" loop which does the "do something" at least once. (notice
that, in the example, the "i=5" and "i<2" would mean that a normal "for"
loop would skip the do something")

And yes, I had to google the usage of multiple commands in the init as well
as in the increment parts of the "for" loop there.  Some languages allow it,
others don't.

> So... I am just here to complain, but my complaints do make sense.

I had to guess to what your complaint actually was, so .. no ? :-\

Regards,
Rudy Wieser


[toc] | [prev] | [next] | [standalone]


#37375

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-25 02:47 -0700
Message-ID<c5305459-cbee-4c13-837d-3596efcf0517@googlegroups.com>
In reply to#37374
Den onsdag 25 september 2019 kl. 09:05:35 UTC+2 skrev R.Wieser:
> Jonas,
> 
> > I think you missed the point Rudy, did you check the picture i posted?
> 
> Noipe, I didn't.   And no, I did not check the picture either.  Phew: A Do
> while and a Do until loop.  Shocking.   Not explaining anything, one way or
> another. :-(
> 
> I /assumed/ that this thread was about the "for" loop.  And pardon me, but
> looking at the rest of your messages (no "do until" form of the "for" loop)
> it looks like I'm right.   Than again,. you did not actually say that, so
> there still is a possibility I'm wrong on that.
> 
> > Because you will have to use negations until your condition is
> > satisfied, and **after** loop finished do what you try to achieve.
> > Thus it ends up.
> >
> > while (this!=that[x]){
> > x++;
> > }
> > do_It();
> 
> I'm sorry, but the above sentence and "code" are gibberish to me.  "use
> negations" ?   Like "a = -a" ?  Something else perhaps ?   And "your
> condition" ?   Where ?   What condition ?  That "this!=that[x]" part ?
> Whats wrong with it (other than it being non-valid ....)  ?  Though that
> condition does not show any kind of "negation", so I'm not even sure you are
> referring to it.  But if not, what /are/ you there referring to ?
> 
> In short: Rephrase please.   What is that condition you want to see, and
> what role should that negation play in it.
> 
> And to be blunt about it: Your initial post in this thread is sorely lacking
> too : It definitily does /not/ specify what you are after. Yes, a I saw that
> you wanted a conditional loop.  The problem is that you included /zero/
> information to what that loop should do, or how it differs from the multiple
> ones we already got. :-(
> 
> Bottom line: When writing something (especially a thread-starter) /think/
> about what you want to tell/ask us.  And than write it as if we, the
> readers, do /not/ have any mind-reading capabilities (meaning: if you do not
> say it we do not know it).   Specify /why/ you posted.
> 
> And yes, that often means you start with a centence *outlining the
> problem/idea/whatever*.  Starting a thread (or even post) with "Well this or
> similar" /when you have not actually said anything/ (there is no "this" yet)
> does not make any sense I'm afraid.
> 
> 
> 
> But after having read the whole it boils down to that there is no "do until"
> form of the "for" loop.  Correct ?
> 
> In that case, why didn't you just /say so/ and ask ?  Or google for it ?
> 
> for (i=5, flag=true ; i<2 || flag ; i++, flag=false) {
>     // do something
> }
> 
> Presto, a "for" loop which does the "do something" at least once. (notice
> that, in the example, the "i=5" and "i<2" would mean that a normal "for"
> loop would skip the do something")
> 
> And yes, I had to google the usage of multiple commands in the init as well
> as in the increment parts of the "for" loop there.  Some languages allow it,
> others don't.
> 
> > So... I am just here to complain, but my complaints do make sense.
> 
> I had to guess to what your complaint actually was, so .. no ? :-\
> 
> Regards,
> Rudy Wieser

In language a negation is no and not, as in while not.
Your searching for "something" using a negation.

The compound statement in for loop, nah that is not beautiful to read...
But it serves  the purpose.

The semantic difference i guess is
Search while not same socks,(compare sock A and B[x]) then pair
VS
Do search until same socks,(compare sock A and B[x]) then pair.

x is here a sock, in the stack of socks you search thru comparing with sock A is the left hand and B is the right hand.

It may seem a small difference, but if compound conditions have a little harder context, the former will be almost impossible to read out all. Compound statements using negations, is just a weird usage but necessary.

Well if your language do not hav "do while" and "do until". 

[toc] | [prev] | [next] | [standalone]


#37377

From"R.Wieser" <address@not.available>
Date2019-09-25 13:13 +0200
Message-ID<qmfi5v$17i4$1@gioia.aioe.org>
In reply to#37375
Jonas,

> In language a negation is no and not, as in while not.
> Your searching for "something" using a negation.

:-) my example of negation was ment as a bit of an over-the-top joke.

But you know what the worst part is ?   You still forgot(?) to explain where 
that "negation" of yours has to do with your proposition.  :-(

> The compound statement in for loop, nah that is not beautiful
> to read...  But it serves  the purpose.

Feel free to come up with a more aesthetic way to do it.

> The semantic difference i guess is
> Search while not same socks,(compare sock A and B[x]) then pair
> VS
> Do search until same socks,(compare sock A and B[x]) then pair.

Skipped example, not valid javascript (don't say I didn't warn you).

> x is here a sock, in the stack of socks you search thru comparing
> with sock A is the left hand and B is the right hand.

You're obsfucating the actual point with crap that has got /nothing/ to do 
with it.  I have no wish to try to dig/guess my way thru that obsfucation. 
Sorry.

> It may seem a small difference, but if compound conditions have a little
> harder context

There is no compound statement in the example you posted.  And no, inverting 
a condition is not in any way the same as a compound statement.

Furthermore, if your example would have used actual valid js I could pointed 
out that you most likely would have been able to invert the comparision 
parameter, negating the need for a negation (and yes, I wrote it that way 
intentionally).

> the former will be almost impossible to read out all.

Really ?    Than you will be in for a hard time I'm afraid.

> Compound statements using negations, is just a weird usage but
> necessary.

Sometimes its necessary, yes.  But if you get confused by it than why not 
use the round brackets around the whole sub-part (negation plus following 
condition) ?   In al other case you could, as already mentioned, simply 
invert the comparision itself.

> Well if your language do not hav "do while" and "do until".

No idea why you said that.  Explain please.    It reads as something that 
should have been followed by a "than do (something else)".


And there I am, at the end of your post, *still* not having any idea of what 
your proposed conditional loop should look like, and even less to what 
problem it should solve. :-(

You know what: I'm going to give you a last chance.   Start with explaining 
what (you think) the problem is (comparing to other, already available loops 
will do just fine).  After that post a SIMPLE mockup using VALID js.    In 
your current case you /should/ even be able to create an actual, working 
example using either a "do until" or a "do while" loop.

If you can't do that I will drop this thread.  It makes no sense to me to 
put effort into keep trying to understand what you are saying as my requests 
for clarity remain unheeded.

Regards,
Rudy Wieser

[toc] | [prev] | [next] | [standalone]


#37378

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-25 05:13 -0700
Message-ID<8cb6e06e-8e1b-41e1-94df-436d86a91437@googlegroups.com>
In reply to#37377
Den onsdag 25 september 2019 kl. 13:14:15 UTC+2 skrev R.Wieser:
> Jonas,
> 
> > In language a negation is no and not, as in while not.
> > Your searching for "something" using a negation.
> 
> :-) my example of negation was ment as a bit of an over-the-top joke.
> 
> But you know what the worst part is ?   You still forgot(?) to explain where 
> that "negation" of yours has to do with your proposition.  :-(
> 
> > The compound statement in for loop, nah that is not beautiful
> > to read...  But it serves  the purpose.
> 
> Feel free to come up with a more aesthetic way to do it.
> 
> > The semantic difference i guess is
> > Search while not same socks,(compare sock A and B[x]) then pair
> > VS
> > Do search until same socks,(compare sock A and B[x]) then pair.
> 
> Skipped example, not valid javascript (don't say I didn't warn you).
> 
> > x is here a sock, in the stack of socks you search thru comparing
> > with sock A is the left hand and B is the right hand.
> 
> You're obsfucating the actual point with crap that has got /nothing/ to do 
> with it.  I have no wish to try to dig/guess my way thru that obsfucation. 
> Sorry.
> 
> > It may seem a small difference, but if compound conditions have a little
> > harder context
> 
> There is no compound statement in the example you posted.  And no, inverting 
> a condition is not in any way the same as a compound statement.
> 
> Furthermore, if your example would have used actual valid js I could pointed 
> out that you most likely would have been able to invert the comparision 
> parameter, negating the need for a negation (and yes, I wrote it that way 
> intentionally).
> 
> > the former will be almost impossible to read out all.
> 
> Really ?    Than you will be in for a hard time I'm afraid.
> 
> > Compound statements using negations, is just a weird usage but
> > necessary.
> 
> Sometimes its necessary, yes.  But if you get confused by it than why not 
> use the round brackets around the whole sub-part (negation plus following 
> condition) ?   In al other case you could, as already mentioned, simply 
> invert the comparision itself.
> 
> > Well if your language do not hav "do while" and "do until".
> 
> No idea why you said that.  Explain please.    It reads as something that 
> should have been followed by a "than do (something else)".
> 
> 
> And there I am, at the end of your post, *still* not having any idea of what 
> your proposed conditional loop should look like, and even less to what 
> problem it should solve. :-(
> 
> You know what: I'm going to give you a last chance.   Start with explaining 
> what (you think) the problem is (comparing to other, already available loops 
> will do just fine).  After that post a SIMPLE mockup using VALID js.    In 
> your current case you /should/ even be able to create an actual, working 
> example using either a "do until" or a "do while" loop.
> 
> If you can't do that I will drop this thread.  It makes no sense to me to 
> put effort into keep trying to understand what you are saying as my requests 
> for clarity remain unheeded.
> 
> Regards,
> Rudy Wieser

No it is not a proposition within JS it is a proposition for loops that do not use negations. do until is not part of JS from what i know only VBA use them. That is my proposition and a statement, then {}

[toc] | [prev] | [next] | [standalone]


#37379

From"R.Wieser" <address@not.available>
Date2019-09-25 15:04 +0200
Message-ID<qmfokj$6u6$1@gioia.aioe.org>
In reply to#37378
Jonas,

> No it is not a proposition within JS it is a proposition for loops that do 
> not use negations.

You are again making no sense there.  /Loops/ do not use negations, 
/conditions/ do.  In other words: You already have what you ask for (you 
/can/ use negations, but you do not /have/ to).

Than again, you /might/ just mean something different by it than inverting a 
conditions result.   The problem is that you still have not explained how 
/you/ are using that "negations" word (which place it actually has in your 
"proposition")

> do until is not part of JS from what i know

Is /that/ the problem ?   You needing a "do until" loop ?   Thats /all/ ? 
And you could not actually say that until I demanded you did ?  WTF!

Look here : https://www.w3schools.com/jsref/jsref_dowhile.asp , and 
especially the first sentence after the (big) word "Example".   I found it 
by plugging "javascript do until loop" into google, where it was the first 
result.

> and a statement, then {}

That does not make any sense to me. And with the lack of (explicitily asked 
for!) example I can't make heads-or-tails from it.

Regards,
Rudy Wieser

P.s.
Drop the top posting.   I already know what my own message was - I wrote it 
myself - and have no need to scroll thru it to get at what you wanted to 
reply to it.  If you /have/ to than top post.   But preferrably quote just 
the relevant parts and delete the rest.

[toc] | [prev] | [next] | [standalone]


#37380

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-25 06:10 -0700
Message-ID<0f8cc81f-884a-45b7-b087-a960c8956912@googlegroups.com>
In reply to#37379
Den onsdag 25 september 2019 kl. 15:04:26 UTC+2 skrev R.Wieser:
> Jonas,
> 
> > No it is not a proposition within JS it is a proposition for loops that do 
> > not use negations.
> 
> You are again making no sense there.  /Loops/ do not use negations, 
> /conditions/ do.  In other words: You already have what you ask for (you 
> /can/ use negations, but you do not /have/ to).
> 
> Than again, you /might/ just mean something different by it than inverting a 
> conditions result.   The problem is that you still have not explained how 
> /you/ are using that "negations" word (which place it actually has in your 
> "proposition")
> 
> > do until is not part of JS from what i know
> 
> Is /that/ the problem ?   You needing a "do until" loop ?   Thats /all/ ? 
> And you could not actually say that until I demanded you did ?  WTF!
> 
> Look here : https://www.w3schools.com/jsref/jsref_dowhile.asp , and 
> especially the first sentence after the (big) word "Example".   I found it 
> by plugging "javascript do until loop" into google, where it was the first 
> result.
> 
> > and a statement, then {}
> 
> That does not make any sense to me. And with the lack of (explicitily asked 
> for!) example I can't make heads-or-tails from it.
> 
> Regards,
> Rudy Wieser
> 
> P.s.
> Drop the top posting.   I already know what my own message was - I wrote it 
> myself - and have no need to scroll thru it to get at what you wanted to 
> reply to it.  If you /have/ to than top post.   But preferrably quote just 
> the relevant parts and delete the rest.

Is one should use do until instead of.... while-> if->break
How hard can it be to understand? 

z=midiEv+1;
	    while(z<nbrOfEV){
		  if(track[rectrack].midiMess[z].data1==track[rectrack].midiMess[midiEv].data1){
			ctm.fillStyle = "#000a4d";
			ctm.fillRect(scrollBarPos-FRONTOFFSET[midiEv]-barLength[midiEv]-6,(PistartX+keyHeight*88)-(keyHeight*(track[rectrack].midiMess[midiEv].data1-8))-1,barLength[midiEv]+6 ,keyHeight+2);
			ctm.fillStyle = pcolor[track[rectrack].midiMess[midiEv].data1];
			ctm.fillRect(scrollBarPos-FRONTOFFSET[midiEv]-barLength[midiEv],(PistartX+keyHeight*88)-(keyHeight*(track[rectrack].midiMess[midiEv].data1-8)), barLength[midiEv]+50,keyHeight);
			break;
		  }
		z++;
		}

[toc] | [prev] | [next] | [standalone]


#37381

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2019-09-25 15:50 +0100
Message-ID<eivmoeptedold0agjpuptcne37buqvitb3@4ax.com>
In reply to#37380
On Wed, 25 Sep 2019 06:10:49 -0700 (PDT), Jonas Thörnvall
<jonas.thornvall@gmail.com> wrote:

  <snip>
>Is one should use do until instead of.... while-> if->break
>How hard can it be to understand? 
>
>z=midiEv+1;
>	    while(z<nbrOfEV){
>		  if(track[rectrack].midiMess[z].data1==track[rectrack].midiMess[midiEv].data1){
>			ctm.fillStyle = "#000a4d";
>			ctm.fillRect(scrollBarPos-FRONTOFFSET[midiEv]-barLength[midiEv]-6,(PistartX+keyHeight*88)-(keyHeight*(track[rectrack].midiMess[midiEv].data1-8))-1,barLength[midiEv]+6 ,keyHeight+2);
>			ctm.fillStyle = pcolor[track[rectrack].midiMess[midiEv].data1];
>			ctm.fillRect(scrollBarPos-FRONTOFFSET[midiEv]-barLength[midiEv],(PistartX+keyHeight*88)-(keyHeight*(track[rectrack].midiMess[midiEv].data1-8)), barLength[midiEv]+50,keyHeight);
>			break;
>		  }
>		z++;
>		}

To summarise, what Jonas if trying to do is :

  z = start;
  while (z < size)
    {
      if (arr[z].data == msg.data)
        {
          update_system_state();
          break
        }
      ++z;
    }  // while


A cleaner way to do it, one that seperates concerns, does find it,
then use it : 

  z = start;
  while ( (z < size) && (arr[z].data != msg.data) )
    ++z;
    
  if (z < size)
    {
        /* z is the value when found, if needed */
      update_system_state();
    }

[toc] | [prev] | [next] | [standalone]


#37382

FromTim Streater <timstreater@greenbee.net>
Date2019-09-25 16:00 +0100
Message-ID<250920191600331779%timstreater@greenbee.net>
In reply to#37381
In article <eivmoeptedold0agjpuptcne37buqvitb3@4ax.com>, John G Harris
<niam@jghnorth.org.uk.invalid> wrote:

>To summarise, what Jonas if trying to do is :
>
>  z = start;
>  while (z < size)
>    {
>      if (arr[z].data == msg.data)
>        {
>          update_system_state();
>          break
>        }
>      ++z;
>    }  // while
>
>
>A cleaner way to do it, one that seperates concerns, does find it,
>then use it : 
>
>  z = start;
>  while ( (z < size) && (arr[z].data != msg.data) )
>    ++z;
>    
>  if (z < size)
>    {
>        /* z is the value when found, if needed */
>      update_system_state();
>    }


Much cleaner, separates what is going on, and is much clearer for
whoever is looking at it some time later.

-- 
"The idea that Bill Gates has appeared like a knight in shining armour to
 lead all customers out of a mire of technological chaos neatly ignores 
 the fact that it was he who, by peddling second-rate technology, led them
 into it in the first place."                             - Douglas Adams

[toc] | [prev] | [next] | [standalone]


#37385

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-25 10:20 -0700
Message-ID<deeecb37-bca4-46bb-b6d2-6df0dcc36154@googlegroups.com>
In reply to#37381
Den onsdag 25 september 2019 kl. 16:50:36 UTC+2 skrev John G Harris:
> On Wed, 25 Sep 2019 06:10:49 -0700 (PDT), Jonas Thörnvall
> <jonas.thornvall@gmail.com> wrote:
> 
>   <snip>
> >Is one should use do until instead of.... while-> if->break
> >How hard can it be to understand? 
> >
> >z=midiEv+1;
> >	    while(z<nbrOfEV){
> >		  if(track[rectrack].midiMess[z].data1==track[rectrack].midiMess[midiEv].data1){
> >			ctm.fillStyle = "#000a4d";
> >			ctm.fillRect(scrollBarPos-FRONTOFFSET[midiEv]-barLength[midiEv]-6,(PistartX+keyHeight*88)-(keyHeight*(track[rectrack].midiMess[midiEv].data1-8))-1,barLength[midiEv]+6 ,keyHeight+2);
> >			ctm.fillStyle = pcolor[track[rectrack].midiMess[midiEv].data1];
> >			ctm.fillRect(scrollBarPos-FRONTOFFSET[midiEv]-barLength[midiEv],(PistartX+keyHeight*88)-(keyHeight*(track[rectrack].midiMess[midiEv].data1-8)), barLength[midiEv]+50,keyHeight);
> >			break;
> >		  }
> >		z++;
> >		}
> 
> To summarise, what Jonas if trying to do is :
> 
>   z = start;
>   while (z < size)
>     {
>       if (arr[z].data == msg.data)
>         {
>           update_system_state();
>           break
>         }
>       ++z;
>     }  // while
> 
> 
> A cleaner way to do it, one that seperates concerns, does find it,
> then use it : 
> 
>   z = start;
>   while ( (z < size) && (arr[z].data != msg.data) )
>     ++z;
>     
>   if (z < size)
>     {
>         /* z is the value when found, if needed */
>       update_system_state();
>     }

Yeah John that is what it is about, but i still think that do until is much more readable.

do until (condition 1 met && condition 2 met....) {      }
then {         }

Nothing beats the clarity of that one not a single doubt what that one is about. I just think the semantics superior.

[toc] | [prev] | [next] | [standalone]


#37386

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-25 10:26 -0700
Message-ID<6e38ab46-bf8d-4422-9491-75019cc471fd@googlegroups.com>
In reply to#37385
Den onsdag 25 september 2019 kl. 19:21:03 UTC+2 skrev Jonas Thörnvall:
> Den onsdag 25 september 2019 kl. 16:50:36 UTC+2 skrev John G Harris:
> > On Wed, 25 Sep 2019 06:10:49 -0700 (PDT), Jonas Thörnvall
> > <jonas.thornvall@gmail.com> wrote:
> > 
> >   <snip>
> > >Is one should use do until instead of.... while-> if->break
> > >How hard can it be to understand? 
> > >
> > >z=midiEv+1;
> > >	    while(z<nbrOfEV){
> > >		  if(track[rectrack].midiMess[z].data1==track[rectrack].midiMess[midiEv].data1){
> > >			ctm.fillStyle = "#000a4d";
> > >			ctm.fillRect(scrollBarPos-FRONTOFFSET[midiEv]-barLength[midiEv]-6,(PistartX+keyHeight*88)-(keyHeight*(track[rectrack].midiMess[midiEv].data1-8))-1,barLength[midiEv]+6 ,keyHeight+2);
> > >			ctm.fillStyle = pcolor[track[rectrack].midiMess[midiEv].data1];
> > >			ctm.fillRect(scrollBarPos-FRONTOFFSET[midiEv]-barLength[midiEv],(PistartX+keyHeight*88)-(keyHeight*(track[rectrack].midiMess[midiEv].data1-8)), barLength[midiEv]+50,keyHeight);
> > >			break;
> > >		  }
> > >		z++;
> > >		}
> > 
> > To summarise, what Jonas if trying to do is :
> > 
> >   z = start;
> >   while (z < size)
> >     {
> >       if (arr[z].data == msg.data)
> >         {
> >           update_system_state();
> >           break
> >         }
> >       ++z;
> >     }  // while
> > 
> > 
> > A cleaner way to do it, one that seperates concerns, does find it,
> > then use it : 
> > 
> >   z = start;
> >   while ( (z < size) && (arr[z].data != msg.data) )
> >     ++z;
> >     
> >   if (z < size)
> >     {
> >         /* z is the value when found, if needed */
> >       update_system_state();
> >     }
> 
> Yeah John that is what it is about, but i still think that do until is much more readable.
> 
> do until (condition 1 met && condition 2 met....) {      }
> then {         }
> 
> Nothing beats the clarity of that one not a single doubt what that one is about. I just think the semantics superior.

I do not say you can't have excluding conditions. I say you should not look for excluding conditions, trying to find what should be found.

until equal

instead of 

while not equal

It is just an opinion but it really matter if there is alot of compound statements in the condition.

[toc] | [prev] | [next] | [standalone]


#37387

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2019-09-25 19:18 +0100
Message-ID<opbnoehqhmp41995chha6a7oemqm29l5n7@4ax.com>
In reply to#37386
On Wed, 25 Sep 2019 10:26:07 -0700 (PDT), Jonas Thörnvall
<jonas.thornvall@gmail.com> wrote:

  <snip>
>while not equal
>
>It is just an opinion but it really matter if there is alot of compound statements in the condition.


  while not equal or not found

or you will get into trouble one day.

  John

[toc] | [prev] | [next] | [standalone]


#37391

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2019-09-25 12:19 -0700
Message-ID<9ee6c578-f5be-4d6c-97ca-dc63379641f6@googlegroups.com>
In reply to#37387
Den onsdag 25 september 2019 kl. 20:18:11 UTC+2 skrev John G Harris:
> On Wed, 25 Sep 2019 10:26:07 -0700 (PDT), Jonas Thörnvall
> <jonas.thornvall@gmail.com> wrote:
> 
>   <snip>
> >while not equal
> >
> >It is just an opinion but it really matter if there is alot of compound statements in the condition.
> 
> 
>   while not equal or not found
> 
> or you will get into trouble one day.
> 
>   John

until equal or EOF in the old days, when we had less memory.

[toc] | [prev] | [next] | [standalone]


#37400

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2019-09-26 10:48 +0100
Message-ID<jb2poe91vl5456rop6okfmjnu2mm39f22k@4ax.com>
In reply to#37391
On Wed, 25 Sep 2019 12:19:57 -0700 (PDT), Jonas Thörnvall
<jonas.thornvall@gmail.com> wrote:

>Den onsdag 25 september 2019 kl. 20:18:11 UTC+2 skrev John G Harris:
>> On Wed, 25 Sep 2019 10:26:07 -0700 (PDT), Jonas Thörnvall
>> <jonas.thornvall@gmail.com> wrote:
>> 
>>   <snip>
>> >while not equal
>> >
>> >It is just an opinion but it really matter if there is alot of compound statements in the condition.
>> 
>> 
>>   while not equal or not found
>> 
>> or you will get into trouble one day.
>
>until equal or EOF in the old days, when we had less memory.

So you agree that there are two reasons for the scan to stop. 

You want a new kind of statement that lets you code just one of them.
You want the compiler to write the other code for you. Now tell us how
you think the compiler will know what needs to be done ?

  John

[toc] | [prev] | [next] | [standalone]


Page 1 of 3  [1] 2 3  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web