Thread View: comp.lang.c
125 messages
125 total messages
Page 3 of 3
Started by fir
Wed, 21 Oct 2026 09:19
Page 3 of 3 • 125 total messages
Re: Taming The Switch-Statement
Author: fir
Date: Thu, 29 Oct 2026 07:28
Date: Thu, 29 Oct 2026 07:28
79 lines
4543 bytes
4543 bytes
Janis Papanagnou pisze: > On 2026-10-28 19:59, Tim Rentsch wrote: >> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: >> >>> On 2026-10-28 03:21, Keith Thompson wrote: >>> >>>> Blaine <cactus_DAC@yahoo.com> writes: >>>> >>>>> Keith Thompson wrote: >>>> >>>> [...] >>>> >>>>>> He doesn't want to. He's made it clear that taking the time to >>>>>> write clearly is beneath him. That's not going to change. >>>>>> Replying to him is a waste of everyone's time. >>>>> >>>>> And then there's Keith Thompson. He makes mistake after mistake, yet >>>>> keeps on trucking never apologizing. He's a waste of everyone's >>>>> time. Go ahead and killfile this guy. I guess I don't mind and it >>>>> will >>>>> improve upon the experience you are having. >>>> >>>> Oh, great, another one. >>>> >>>> This "Blaine" person has apparently made up some weird fantasy >>>> about me, based on a recent brief interaction in comp.os.linux.misc >>>> and comp.lang.python. I suggest not engaging with his attempted >>>> harassment. >>> >>> Interestingly I don't see his post. (He seems to be in my killfile.) >>> A long period of time must have passed since then since I even don't >>> recall his name. >>> >>> I think people can make an educated decision themselves about whom >>> they killfile and how they waste their time. ;-) >> >> Please don't make things worse by encouraging the blatherskites. >> >> P.S. For those unfamiliar with the word blatherskite, here is a >> partial definition >> >> fir is a blatherskite; >> >> anyone who routinely responds to any blatherskite is a >> blatherskite. > > Okay, by that definition you primarily named Keith a "blatherskite". > > Now you were responding to me, someone responding to a "blatherskite's > blatherskite" person, which by above (absolutely pointless) recursive > definition is also a "blatherskite". And since you respond to me, per > (your) definition a blatherskite's blatherskite's blatherskite person, > you are a blatherskite's blatherskite's blatherskite's blatherskite. > Wow. > in my part of clc i participated this snake began with bartc (as far as i remember at least).. > Was it clever to provide such a definition outing you as blatherskite? > Have we won any insight by your post? (I mean other than what we know > already about you, or about anyone else here.) > > Better abstain and leave the decisions who is posting what and replying > to whom to the individuals here. In case you missed it; above quoted: > > >> I think people can make an educated decision themselves about whom > >> they killfile and how they waste their time. ;-) > > In your case please substitute ". ;-)" by "! :-/" in my quote, as > you seem to have had issues understanding that. > > Thanks. > > Janis, trap ignore SIGTIM >
Re: Taming The Switch-Statement
Author: fir
Date: Thu, 29 Oct 2026 07:32
Date: Thu, 29 Oct 2026 07:32
84 lines
4782 bytes
4782 bytes
fir pisze: > Janis Papanagnou pisze: >> On 2026-10-28 19:59, Tim Rentsch wrote: >>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: >>> >>>> On 2026-10-28 03:21, Keith Thompson wrote: >>>> >>>>> Blaine <cactus_DAC@yahoo.com> writes: >>>>> >>>>>> Keith Thompson wrote: >>>>> >>>>> [...] >>>>> >>>>>>> He doesn't want to. He's made it clear that taking the time to >>>>>>> write clearly is beneath him. That's not going to change. >>>>>>> Replying to him is a waste of everyone's time. >>>>>> >>>>>> And then there's Keith Thompson. He makes mistake after mistake, yet >>>>>> keeps on trucking never apologizing. He's a waste of everyone's >>>>>> time. Go ahead and killfile this guy. I guess I don't mind and >>>>>> it will >>>>>> improve upon the experience you are having. >>>>> >>>>> Oh, great, another one. >>>>> >>>>> This "Blaine" person has apparently made up some weird fantasy >>>>> about me, based on a recent brief interaction in comp.os.linux.misc >>>>> and comp.lang.python. I suggest not engaging with his attempted >>>>> harassment. >>>> >>>> Interestingly I don't see his post. (He seems to be in my killfile.) >>>> A long period of time must have passed since then since I even don't >>>> recall his name. >>>> >>>> I think people can make an educated decision themselves about whom >>>> they killfile and how they waste their time. ;-) >>> >>> Please don't make things worse by encouraging the blatherskites. >>> >>> P.S. For those unfamiliar with the word blatherskite, here is a >>> partial definition >>> >>> fir is a blatherskite; >>> >>> anyone who routinely responds to any blatherskite is a >>> blatherskite. >> >> Okay, by that definition you primarily named Keith a "blatherskite". >> >> Now you were responding to me, someone responding to a "blatherskite's >> blatherskite" person, which by above (absolutely pointless) recursive >> definition is also a "blatherskite". And since you respond to me, per >> (your) definition a blatherskite's blatherskite's blatherskite person, >> you are a blatherskite's blatherskite's blatherskite's blatherskite. >> Wow. >> > > in my part of clc i participated this snake began with bartc (as far as > i remember at least).. > (thou wait, before it was bagin by some who got a problem with my mistypes - but i dont remember who it was) > > >> Was it clever to provide such a definition outing you as blatherskite? >> Have we won any insight by your post? (I mean other than what we know >> already about you, or about anyone else here.) >> >> Better abstain and leave the decisions who is posting what and replying >> to whom to the individuals here. In case you missed it; above quoted: >> >> >> I think people can make an educated decision themselves about whom >> >> they killfile and how they waste their time. ;-) >> >> In your case please substitute ". ;-)" by "! :-/" in my quote, as >> you seem to have had issues understanding that. >> >> Thanks. >> >> Janis, trap ignore SIGTIM >> >
Re: Taming The Switch-Statement
Author: Rosario19
Date: Thu, 29 Oct 2026 07:38
Date: Thu, 29 Oct 2026 07:38
17 lines
2004 bytes
2004 bytes
On Thu, 29 Oct 2026 08:30:33 +0100, Rosario19 wrote:
>for(x=1;x<20;++x)
> {if(x%2==0) printf("%d divides by 2\n",x);
> if(x%3==0) printf("%d divides by 3\n",x);
> if(x%3!=0&&x%2!=0)
> printf("%d no divides (by 3 or 2)\n",x);
> }
int y,x=0;
label:
y=1;++x;
if(x%2==0) {printf("%d divides by 2\n",x);y=0;}
if(x%3==0) {printf("%d divides by 3\n",x);y=0;}
if(y)printf("%d no divides (by 3 or 2)\n",x);
if(x<20)goto label;
Re: Taming The Switch-Statement
Author: Rosario19
Date: Thu, 29 Oct 2026 07:41
Date: Thu, 29 Oct 2026 07:41
24 lines
2210 bytes
2210 bytes
On Thu, 29 Oct 2026 08:38:06 +0100, Rosario19 <Ros@invalid.invalid>
wrote:
>On Thu, 29 Oct 2026 08:30:33 +0100, Rosario19 wrote:
>
>>for(x=1;x<20;++x)
>> {if(x%2==0) printf("%d divides by 2\n",x);
>> if(x%3==0) printf("%d divides by 3\n",x);
>> if(x%3!=0&&x%2!=0)
>> printf("%d no divides (by 3 or 2)\n",x);
>> }
>
>
>int y,x=0;
>label:
>y=1;++x;
>if(x%2==0) {printf("%d divides by 2\n",x);y=0;}
>if(x%3==0) {printf("%d divides by 3\n",x);y=0;}
>if(y)printf("%d no divides (by 3 or 2)\n",x);
>if(x<20)goto label;
if(x<19)goto label,
x is 18, goes in label print 19
19 exit
Re: Taming The Switch-Statement
Author: fir
Date: Thu, 29 Oct 2026 11:31
Date: Thu, 29 Oct 2026 11:31
151 lines
5499 bytes
5499 bytes
Rosario19 pisze:
> On Mon, 26 Oct 2026 18:06:51 +0100, fir wrote:
>> bartc pisze:
>>> On 26/10/2026 16:45, fir wrote:
>>>> bartc pisze:
>>>>>> without or (or something analogic) as i understand if im not wrong
>>>>>> you cant
>>>>> You seem fixated on that 'or'. Either use 'else', or create 'or' as
>>>>> an alias as I suggested.
>>>>
>>>> imo you should try to understand the example
>>>>
>>>> for(int i = 1; i < 20; i++)
>>>> {
>>>>
>>>> if(x%2==0) printf("\n divides by 2");
>>>> or if(x%3==0) printf("\n divides by 3");
>>>> else printf("\n no divides (by 2 or 3)");
>>>> }
>>>>
>>>> you understand how this would work? i think you do
>>>>
>>>> and how in normal c without this "or" it would look,
>>>> for exampel in your if else model?
>>>
>>> Show me exactly what the output should be, when it is written like this:
>>>
>>> if(x%2==0) printf("\n%d divides by 2", i);
>>> or if(x%3==0) printf("\n%d divides by 3", i);
>>> else printf("\n%d no divides (by 2 or 3)", i);
>>>
>>> You might also want to look at the FizzBuzz program.
>>>
>> 1 no divides (by 2 or 3)
>> 2 divides by 2
>> 3 divides by 3
>> 4 divides by 2
>> 5 no divides (by 2 or 3)
>> 6 divides by 2
>> 6 divides by 3
>> 7 no divides (by 2 or 3)
>> 8 divides by 2
>> 9 divides by 3
>> 10 divides by 2
>> 11 no divides (by 2 or 3)
>> 12 divides by 2
>> 12 divides by 3
>> 13 no divides (by 2 or 3)
>> 14 divides by 2
>> 15 divides by 3
>> 16 divides by 2
>> 17 no divides (by 2 or 3)
>> 18 divides by 2
>> 18 divides by 3
>> 19 no divides (by 2 or 3)
>
> for(x=1;x<20;++x)
> {if(x%2==0) printf("%d divides by 2\n",x);
> if(x%3==0) printf("%d divides by 3\n",x);
> if(x%3!=0&&x%2!=0)
> printf("%d no divides (by 3 or 2)\n",x);
> }
>
explicitely repeating calculation is not a good thing here
introducing separate soecial variable to handle this also not
normally you would need something like this above and this onei guess
for(x=1;x<20;++x)
{
int taken =0;
if(x%2==0)taken++, printf("%d divides by 2\n",x);
if(x%3==0) taken++, printf("%d divides by 3\n",x);
if(!taken)
printf("%d no divides (by 3 or 2)\n",x);
}
but both are kinda violations
where
for(x=1;x<20;++x)
{
if(x%2==0) printf("%d divides by 2\n",x);
or if(x%3==0) printf("%d divides by 3\n",x);
else printf("%d no divides (by 3 or 2)\n",x);
}
is not
(and i think there are more such combination you cannot expres
with if else , though i not checked for example if
for(x=1;x<20;++x)
{
if(x%2==0) printf("%d divides by 2\n",x);
and if(x%3==0) printf("%d divides by 3\n",x);
else printf("%d no divides (by both 3 and 2)\n",x);
}
this you can express (seems also no as the both %2 %3 you need to go
thru so you cant goto and if you go thru you need to remember the states
%2 else goto B
// %2 tru
%3 else goto D
//%2%3 tru
D
%2 tru
%3 false
B: // %2 fale
%3 else goto C
//%2 false %3 true here
C
//%2%3 false here
so in fact you CAN unwind this
if(x%2==0) printf("%d divides by 2\n",x); else goto mod2false;
if(x%3==0) printf("%d divides by 3\n",x); else goto mod2true3false;
goto out;
mod2true3false:
goto out;
mod2false:
if(x%3==0) printf("%d divides by 3\n",x); else mod2false3false;
goto out;
mod2false3false:
printf("%d no divides (by both 3 and 2)\n",x);
out:
but its also bad - you repeat the mod 3 calculation in 2 branches
on assembly level it seem you also need to hold a state but its inner
state can be uin register you dont need name it etc
Re: Taming The Switch-Statement
Author: chine.bleu
Date: Thu, 29 Oct 2026 14:34
Date: Thu, 29 Oct 2026 14:34
14 lines
1908 bytes
1908 bytes
fir wrote: >> >> What is your war using C reserved words in existing syntax? >> > > its for illustrartion A LeRoy Neiman illustration. -- Siri Seal of Disavowal #777-000. Disavowed. Denied. @ NO KINGS For I desire mercy not sacrifice. /|\ The Church of the Holey Apple .signature 5.5 / \ of Discordian Mysteries. This post insults Islam. Mohamed
Re: Taming The Switch-Statement
Author: Tim Rentsch
Date: Fri, 30 Oct 2026 05:16
Date: Fri, 30 Oct 2026 05:16
23 lines
2258 bytes
2258 bytes
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: > On 2026-10-28 19:59, Tim Rentsch wrote: > >> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: >> >>> I think people can make an educated decision themselves about >>> whom they killfile and how they waste their time. ;-) >> >> Please don't make things worse by encouraging the blatherskites. >> >> P.S. For those unfamiliar with the word blatherskite, here is a >> partial definition >> >> fir is a blatherskite; >> >> anyone who routinely responds to any blatherskite is a >> blatherskite. > > Okay, by that definition you primarily named Keith a > "blatherskite". I think you missed the word "routinely" in my statement.
Re: BizFuss (was Re: Taming The Switch-Statement)
Author: Lawrence D’Oliveiro
Date: Fri, 30 Oct 2026 08:27
Date: Fri, 30 Oct 2026 08:27
23 lines
2354 bytes
2354 bytes
On Thu, 29 Oct 2026 08:30:33 +0100, Rosario19 wrote:
> for(x=1;x<20;++x)
> {if(x%2==0) printf("%d divides by 2\n",x);
> if(x%3==0) printf("%d divides by 3\n",x);
> if(x%3!=0&&x%2!=0)
> printf("%d no divides (by 3 or 2)\n",x);
> }
Generalization I call “bizzfuzz” -- substitute whatever
factors and limit you want:
factors = (2, 3, 5, 7) # factors to be checked in order
limit = 200
for n in range(1, limit + 1) :
i = (list(n % factors[j] == 0 for j in range(len(factors))) + [True]).index(True)
if i < len(factors) :
print("%d is divisible by %d" % (n, factors[i]))
else :
print("%d is not divisible by any of (%s)" % (n, ", ".join(str(f) for f in factors)))
#end if
#end for
Re: BizFuss (was Re: Taming The Switch-Statement)
Author: bartc
Date: Fri, 30 Oct 2026 11:47
Date: Fri, 30 Oct 2026 11:47
70 lines
3695 bytes
3695 bytes
On 30/10/2026 08:27, Lawrence D’Oliveiro wrote:
> On Thu, 29 Oct 2026 08:30:33 +0100, Rosario19 wrote:
>
>> for(x=1;x<20;++x)
>> {if(x%2==0) printf("%d divides by 2\n",x);
>> if(x%3==0) printf("%d divides by 3\n",x);
>> if(x%3!=0&&x%2!=0)
>> printf("%d no divides (by 3 or 2)\n",x);
>> }
>
> Generalization I call “bizzfuzz” -- substitute whatever
> factors and limit you want:
>
> factors = (2, 3, 5, 7) # factors to be checked in order
> limit = 200
>
> for n in range(1, limit + 1) :
> i = (list(n % factors[j] == 0 for j in range(len(factors))) + [True]).index(True)
> if i < len(factors) :
> print("%d is divisible by %d" % (n, factors[i]))
> else :
> print("%d is not divisible by any of (%s)" % (n, ", ".join(str(f) for f in factors)))
Why not just this here:
print(n, " is not divisible by any of ", factors)
In any case, this doesn't do the same thing. It generates this for example:
167 is not divisible by any of (2, 3, 5, 7)
168 is divisible by 2
169 is not divisible by any of (2, 3, 5, 7)
It only shows one of the factors then proceeds to the next. It should
show all that are true.
This was supposed to be my version of your code, but it does the task
properly:
factors := (2, 3, 5, 7)
limit := 200
for n to limit do
x := 0
for f in factors when n rem f = 0 do
println n, "is divisible by", f
++x
end
unless x then
println n, "is not divisible by any of", factors
end
end
That output becomes:
167 is not divisible by any of (2,3,5,7)
168 is divisible by 2
168 is divisible by 3
168 is divisible by 7
169 is not divisible by any of (2,3,5,7)
Sizes (with hard tabs and no comments):
Your Python: 340 characters
Mine: 222 (as above; scripting)
C: 393 (not shown; not elegant)
Mine: 314 (not shown; systems lang)
Re: BizFuss (was Re: Taming The Switch-Statement)
Author: bartc
Date: Fri, 30 Oct 2026 15:36
Date: Fri, 30 Oct 2026 15:36
51 lines
3164 bytes
3164 bytes
On 30/10/2026 08:27, Lawrence D’Oliveiro wrote:
> On Thu, 29 Oct 2026 08:30:33 +0100, Rosario19 wrote:
>
>> for(x=1;x<20;++x)
>> {if(x%2==0) printf("%d divides by 2\n",x);
>> if(x%3==0) printf("%d divides by 3\n",x);
>> if(x%3!=0&&x%2!=0)
>> printf("%d no divides (by 3 or 2)\n",x);
>> }
>
> Generalization I call “bizzfuzz” -- substitute whatever
> factors and limit you want:
>
> factors = (2, 3, 5, 7) # factors to be checked in order
> limit = 200
>
> for n in range(1, limit + 1) :
> i = (list(n % factors[j] == 0 for j in range(len(factors))) + [True]).index(True)
> if i < len(factors) :
> print("%d is divisible by %d" % (n, factors[i]))
> else :
> print("%d is not divisible by any of (%s)" % (n, ", ".join(str(f) for f in factors)))
> #end if
> #end for
This a Python version that displays all the factors that work (so it
corresponds to the behaviour of the C):
factors = [2, 3, 5, 7]
limit = 200
for n in range(1, limit + 1) :
d = []
for f in factors:
if n % f == 0: d.append(f)
if len(d):
print(n, "is divisible by", d)
else:
print(n, "is not divisible by any of", factors)
Output for the 168 example in my other post will be:
167 is not divisible by any of [2, 3, 5, 7]
168 is divisible by [2, 3, 7]
169 is not divisible by any of [2, 3, 5, 7]
Size is 226 characters with hard tabs.
Re: Taming The Switch-Statement
Author: Chris M. Thomasson
Date: Fri, 30 Oct 2026 18:16
Date: Fri, 30 Oct 2026 18:16
28 lines
3165 bytes
3165 bytes
On 10/29/2026 12:05 AM, fir wrote: > Chris M. Thomasson pisze: >> On 10/27/2026 1:36 PM, fir wrote: >>> Chris M. Thomasson pisze: >>>> On 10/27/2026 12:42 PM, fir wrote: >>>> [...] >>>>> now those clowns appearing like here are really rare ocasins to me >>>> >>>> Did they go to the clown school as you? >>>> >>> >>> no - you go to asom school of bulshit with your colegues >>> >>> then dont expect that normal people who dislike bulshit (as me) >>> will take it... >>> >>> ofc for yours alike no-bulshit is some alien think and bulshit is >>> your home..so you come with buckets full of bulshit here .. drowning >>> it more and more on poor clc >> Sigh. I just pity you when your access to AI goes off. Say internet >> down. You won't be able to create anymore... Oh well... > > its ok but i think you could bear your worries in silence.. you can > also pray for me if you want > > Touche! :^)
Re: BizFuss (was Re: Taming The Switch-Statement)
Author: Keith Thompson
Date: Fri, 30 Oct 2026 19:04
Date: Fri, 30 Oct 2026 19:04
25 lines
2373 bytes
2373 bytes
Lawrence D’Oliveiro <ldo@nz.invalid> writes:
> On Thu, 29 Oct 2026 08:30:33 +0100, Rosario19 wrote:
>
>> for(x=1;x<20;++x)
>> {if(x%2==0) printf("%d divides by 2\n",x);
>> if(x%3==0) printf("%d divides by 3\n",x);
>> if(x%3!=0&&x%2!=0)
>> printf("%d no divides (by 3 or 2)\n",x);
>> }
>
> Generalization I call “bizzfuzz” -- substitute whatever
> factors and limit you want:
>
> factors = (2, 3, 5, 7) # factors to be checked in order
> limit = 200
>
> for n in range(1, limit + 1) :
[SNIP]
comp.lang.python is down the hall, just past the water cooler, on
the left.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Python is the universal language (Was: BizFuss (was Re: Taming The Switch-Statement))
Author: Kenny McCormack
Date: Fri, 30 Oct 2026 20:10
Date: Fri, 30 Oct 2026 20:10
16 lines
1676 bytes
1676 bytes
In article <11c2poh$gqls$2@kst.eternal-september.org>, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: ... >[SNIP] > >comp.lang.python is down the hall, just past the water cooler, on >the left. Haven't you heard? Python is the new universal language and is, thus, on-topic wherever you go. -- The randomly chosen signature file that would have appeared here is more than 4-ish lines long. As such, it violates one or more Usenet RFCs. In order to remain in compliance with said RFCs, the actual sig can be found at the following URL: http://user.xmission.com/~gazelle/Sigs/Aspergers
Re: Taming The Switch-Statement
Author: Rosario19
Date: Sat, 31 Oct 2026 09:54
Date: Sat, 31 Oct 2026 09:54
56 lines
3248 bytes
3248 bytes
On Thu, 29 Oct 2026 12:31:48 +0100, fir wrote:
>Rosario19 pisze:
>> On Mon, 26 Oct 2026 18:06:51 +0100, fir wrote:
>>> bartc pisze:
>>>> On 26/10/2026 16:45, fir wrote:
>>>>> bartc pisze:
>>>>>>> without or (or something analogic) as i understand if im not wrong
>>>>>>> you cant
>>>>>> You seem fixated on that 'or'. Either use 'else', or create 'or' as
>>>>>> an alias as I suggested.
>>> 1 no divides (by 2 or 3)
>>> 2 divides by 2
>>> 3 divides by 3
>>> 4 divides by 2
>>> 5 no divides (by 2 or 3)
>>> 6 divides by 2
>>> 6 divides by 3
>>> 7 no divides (by 2 or 3)
>>> 8 divides by 2
>>> 9 divides by 3
>>> 10 divides by 2
>>> 11 no divides (by 2 or 3)
>>> 12 divides by 2
>>> 12 divides by 3
>>> 13 no divides (by 2 or 3)
>>> 14 divides by 2
>>> 15 divides by 3
>>> 16 divides by 2
>>> 17 no divides (by 2 or 3)
>>> 18 divides by 2
>>> 18 divides by 3
>>> 19 no divides (by 2 or 3)
>
> if(x%2==0) printf("%d divides by 2\n",x); else goto mod2false;
> if(x%3==0) printf("%d divides by 3\n",x); else goto mod2true3false;
> goto out;
>mod2true3false:
> goto out;
>
>mod2false:
> if(x%3==0) printf("%d divides by 3\n",x); else mod2false3false;
> goto out;
>mod2false3false:
> printf("%d no divides (by both 3 and 2)\n",x);
>out:
>
>but its also bad - you repeat the mod 3 calculation in 2 branches
>
>on assembly level it seem you also need to hold a state but its inner
>state can be uin register you dont need name it etc
if(x%2==0) printf("%d divides by 2\n",x); else goto mod2false;
is wrong because before the else has to be executed
if(x%3==0) printf("%d divides by 3\n",x);
Re: BizFuss (was Re: Taming The Switch-Statement)
Author: Rosario19
Date: Sat, 31 Oct 2026 10:36
Date: Sat, 31 Oct 2026 10:36
60 lines
3515 bytes
3515 bytes
On Fri, 30 Oct 2026 08:27:59 -0000 (UTC), Lawrence DÿOliveiro wrote:
>On Thu, 29 Oct 2026 08:30:33 +0100, Rosario19 wrote:
>
>> for(x=1;x<20;++x)
>> {if(x%2==0) printf("%d divides by 2\n",x);
>> if(x%3==0) printf("%d divides by 3\n",x);
>> if(x%3!=0&&x%2!=0)
>> printf("%d no divides (by 3 or 2)\n",x);
>> }
>
>Generalization I call “bizzfuzz” -- substitute whatever
>factors and limit you want:
>
> factors = (2, 3, 5, 7) # factors to be checked in order
> limit = 200
>
> for n in range(1, limit + 1) :
> i = (list(n % factors[j] == 0 for j in range(len(factors))) + [True]).index(True)
> if i < len(factors) :
> print("%d is divisible by %d" % (n, factors[i]))
> else :
> print("%d is not divisible by any of (%s)" % (n, ", ".join(str(f) for f in factors)))
> #end if
> #end for
In APL modulo translation is 80 characters, 1 line
2 3
7{leftbrace}a{leftarrow}{alpha}{diamond}{leftbrace}0={notequalunderbar}k{leftarrow}a/{dieresistilde}0=a{stile}{omega}:{quad}{leftarrow}{omega},{apostrophe}
is not divisible by
{apostrophe},a{diamond}{quad}{leftarrow}{omega},{apostrophe} is
divisible by
{apostrophe},k{rightbrace}{dieresis}{iota}{omega}{rightbrace}20
2 3 7{a¼©À{0=?k¼a/¡0=a|¹:²¼¹,' is not divisible by ',aÀ²¼¹,' is
divisible by ',k}¡°¹}20
1 is not divisible by 2 3 7
2 is divisible by 2
3 is divisible by 3
4 is divisible by 2
5 is not divisible by 2 3 7
6 is divisible by 2 3
7 is divisible by 7
8 is divisible by 2
9 is divisible by 3
10 is divisible by 2
11 is not divisible by 2 3 7
12 is divisible by 2 3
13 is not divisible by 2 3 7
14 is divisible by 2 7
15 is divisible by 3
16 is divisible by 2
17 is not divisible by 2 3 7
18 is divisible by 2 3
19 is not divisible by 2 3 7
20 is divisible by 2
Re: BizFuss (was Re: Taming The Switch-Statement)
Author: Rosario19
Date: Sat, 31 Oct 2026 10:39
Date: Sat, 31 Oct 2026 10:39
19 lines
2204 bytes
2204 bytes
On Fri, 30 Oct 2026 11:47:59 +0000, bartc wrote: >That output becomes: > > 167 is not divisible by any of (2,3,5,7) > 168 is divisible by 2 > 168 is divisible by 3 > 168 is divisible by 7 > 169 is not divisible by any of (2,3,5,7) > >Sizes (with hard tabs and no comments): > > Your Python: 340 characters > Mine: 222 (as above; scripting) > C: 393 (not shown; not elegant) > Mine: 314 (not shown; systems lang) The APL one is 80 characters Is more long the string to write that the code to execute...
Re: BizFuss (was Re: Taming The Switch-Statement)
Author: bartc
Date: Sat, 31 Oct 2026 12:21
Date: Sat, 31 Oct 2026 12:21
79 lines
4189 bytes
4189 bytes
On 31/10/2026 10:39, Rosario19 wrote:
> On Fri, 30 Oct 2026 11:47:59 +0000, bartc wrote:
>
>> That output becomes:
>>
>> 167 is not divisible by any of (2,3,5,7)
>> 168 is divisible by 2
>> 168 is divisible by 3
>> 168 is divisible by 7
>> 169 is not divisible by any of (2,3,5,7)
>>
>> Sizes (with hard tabs and no comments):
>>
>> Your Python: 340 characters
>> Mine: 222 (as above; scripting)
>> C: 393 (not shown; not elegant)
>> Mine: 314 (not shown; systems lang)
>
> The APL one is 80 characters
That's not quite right:
* You're using 2,3,7 not 2,3,5,7, which would add 2 characters
* You're doing 20 iterations not 200 (adds 1 more character!)
* You missed out 'any of ' (adds 6 characters, however your output seems
to have unnecessary space so perhaps that can be trimmed)
> Is more long the string to write that the code to execute...
The point about the version I posted is that it does the correct task
but much cleanly than Python, which had lots of unnecessary
complications. So anyone could follow it.
But I modified my version to be compact, and it looks like this:
f:=(2,3,5,7)
for n to 20 do
d::=()
for x in f when n rem x=0 do d&:=x od
?n,(d|"is divisible by"|"is not divisible by"),(d|d|f)
od
This is 134 characters (131 without those indents). It suffers from
named symbols such as 'rem' needing 5 characters rather than 1.
Note that your APL (with '5' added), because it uses Unicode, takes up
105 bytes; my version is still 131/134 bytes while still just about
being understandable.
That's pretty good even if a big chunk of the APL (38 characters/bytes)
is those strings.
It would be interesting if somebody were to post a version in code-golf C.
(The output from my version here is this, but it can vary provided the
same info is displayed:)
1 is not divisible by (2,3,5,7)
2 is divisible by (2)
3 is divisible by (3)
4 is divisible by (2)
5 is divisible by (5)
6 is divisible by (2,3)
7 is divisible by (7)
8 is divisible by (2)
9 is divisible by (3)
10 is divisible by (2,5)
11 is not divisible by (2,3,5,7)
12 is divisible by (2,3)
13 is not divisible by (2,3,5,7)
14 is divisible by (2,7)
15 is divisible by (3,5)
16 is divisible by (2)
17 is not divisible by (2,3,5,7)
18 is divisible by (2,3)
19 is not divisible by (2,3,5,7)
20 is divisible by (2,5)
Re: BizFuss (was Re: Taming The Switch-Statement)
Author: bartc
Date: Sat, 31 Oct 2026 13:27
Date: Sat, 31 Oct 2026 13:27
73 lines
4379 bytes
4379 bytes
On 31/10/2026 12:21, bartc wrote:
> On 31/10/2026 10:39, Rosario19 wrote:
>> On Fri, 30 Oct 2026 11:47:59 +0000, bartc wrote:
>>
>>> That output becomes:
>>>
>>> 167 is not divisible by any of (2,3,5,7)
>>> 168 is divisible by 2
>>> 168 is divisible by 3
>>> 168 is divisible by 7
>>> 169 is not divisible by any of (2,3,5,7)
>>>
>>> Sizes (with hard tabs and no comments):
>>>
>>> Your Python: 340 characters
>>> Mine: 222 (as above; scripting)
>>> C: 393 (not shown; not elegant)
>>> Mine: 314 (not shown; systems lang)
>>
>> The APL one is 80 characters
>
> That's not quite right:
>
> * You're using 2,3,7 not 2,3,5,7, which would add 2 characters
>
> * You're doing 20 iterations not 200 (adds 1 more character!)
>
> * You missed out 'any of ' (adds 6 characters, however your output seems
> to have unnecessary space so perhaps that can be trimmed)
>
>> Is more long the string to write that the code to execute...
>
> The point about the version I posted is that it does the correct task
> but much cleanly than Python, which had lots of unnecessary
> complications. So anyone could follow it.
>
> But I modified my version to be compact, and it looks like this:
>
> f:=(2,3,5,7)
> for n to 20 do
> d::=()
> for x in f when n rem x=0 do d&:=x od
> ?n,(d|"is divisible by"|"is not divisible by"),(d|d|f)
> od
>
> This is 134 characters (131 without those indents). It suffers from
> named symbols such as 'rem' needing 5 characters rather than 1.
>
> Note that your APL (with '5' added), because it uses Unicode, takes up
> 105 bytes; my version is still 131/134 bytes while still just about
> being understandable.
The following is 118 bytes/chars ('%' means integer division). But it
removes the duplicate parts of the strings, which could probably be done
in APL too.
f:=(2,3,5,7)
for n to 20 do
d::=()
for x in f when n%x*x=n do d&:=x od
?n,(d|"is"|"is not"),"divisible by",(d|d|f)
od
More reductions are possible via tweaks in this syntax, with the result
still using both standard ASCII, and being more understandable compared to:
2 3 5 7{a¼©À{0=?k¼a/¡0=a|¹:²¼¹,' is not divisible by ',aÀ²¼¹,' is
divisible by ',k}¡°¹}20
(But I'm not making any such changes! I avoid syntax that is too quaint.
At best I might allow (a|a|b), the equivalent of (a?a:b) in C, to be
written as (a||b). That would save one character here, but it is also
genuinely useful.)
Re: BizFuss (was Re: Taming The Switch-Statement)
Author: Rosario19
Date: Sat, 31 Oct 2026 13:30
Date: Sat, 31 Oct 2026 13:30
72 lines
3775 bytes
3775 bytes
On Sat, 31 Oct 2026 12:21:13 +0000, bartc <bc@freeuk.com> wrote:
>On 31/10/2026 10:39, Rosario19 wrote:
>> On Fri, 30 Oct 2026 11:47:59 +0000, bartc wrote:
>>
>>> That output becomes:
>>>
>>> 167 is not divisible by any of (2,3,5,7)
>>> 168 is divisible by 2
>>> 168 is divisible by 3
>>> 168 is divisible by 7
>>> 169 is not divisible by any of (2,3,5,7)
>>>
>>> Sizes (with hard tabs and no comments):
>>>
>>> Your Python: 340 characters
>>> Mine: 222 (as above; scripting)
>>> C: 393 (not shown; not elegant)
>>> Mine: 314 (not shown; systems lang)
>>
>> The APL one is 80 characters
>
>That's not quite right:
>
>* You're using 2,3,7 not 2,3,5,7, which would add 2 characters
>
>* You're doing 20 iterations not 200 (adds 1 more character!)
code I posted is 2 input one left (the list 2 3 7) and one in the
right (the number 20) and the APL function in the middle.
80 charaters refer only for APL function.
So the number of characters of the function + the input is more than
80. It is possible change the input [input left the list 2 3 5 7,
input right the integer 200] for have this
2 3 5 7{a???{0=?k?a/?0=a|?:???,' is not divisible by ',a????,' is
divisible by ',k}¨??}200
1 is not divisible by 2 3 5 7
2 is divisible by 2
3 is divisible by 3
4 is divisible by 2
5 is divisible by 5
6 is divisible by 2 3
7 is divisible by 7
8 is divisible by 2
9 is divisible by 3
10 is divisible by 2 5
11 is not divisible by 2 3 5 7
12 is divisible by 2 3
13 is not divisible by 2 3 5 7
14 is divisible by 2 7
15 is divisible by 3 5
16 is divisible by 2
17 is not divisible by 2 3 5 7
18 is divisible by 2 3
19 is not divisible by 2 3 5 7
20 is divisible by 2 5
21 is divisible by 3 7
22 is divisible by 2
23 is not divisible by 2 3 5 7
24 is divisible by 2 3
25 is divisible by 5
...............
196 is divisible by 2 7
197 is not divisible by 2 3 5 7
198 is divisible by 2 3
199 is not divisible by 2 3 5 7
200 is divisible by 2 5
Re: BizFuss (was Re: Taming The Switch-Statement)
Author: bartc
Date: Sat, 31 Oct 2026 13:38
Date: Sat, 31 Oct 2026 13:38
59 lines
3813 bytes
3813 bytes
On 31/10/2026 13:30, Rosario19 wrote:
> On Sat, 31 Oct 2026 12:21:13 +0000, bartc <bc@freeuk.com> wrote:
>
>> On 31/10/2026 10:39, Rosario19 wrote:
>>> On Fri, 30 Oct 2026 11:47:59 +0000, bartc wrote:
>>>
>>>> That output becomes:
>>>>
>>>> 167 is not divisible by any of (2,3,5,7)
>>>> 168 is divisible by 2
>>>> 168 is divisible by 3
>>>> 168 is divisible by 7
>>>> 169 is not divisible by any of (2,3,5,7)
>>>>
>>>> Sizes (with hard tabs and no comments):
>>>>
>>>> Your Python: 340 characters
>>>> Mine: 222 (as above; scripting)
>>>> C: 393 (not shown; not elegant)
>>>> Mine: 314 (not shown; systems lang)
>>>
>>> The APL one is 80 characters
>>
>> That's not quite right:
>>
>> * You're using 2,3,7 not 2,3,5,7, which would add 2 characters
>>
>> * You're doing 20 iterations not 200 (adds 1 more character!)
>
> code I posted is 2 input one left (the list 2 3 7) and one in the
> right (the number 20) and the APL function in the middle.
>
> 80 charaters refer only for APL function.
OK. I trusted you and didn't bother counting!
But then the 80 characters is misleading if comparing with my figures
where the inputs (factors and iterations) are hard-coded within the source.
So the true figure with 2 3 5 7 and let's say 20 iterations still, would
be 89 characters. I posted just now a version of mine, which still has
some conventional structure, with 118 characters, so it's not far off.
> So the number of characters of the function + the input is more than
> 80. It is possible change the input [input left the list 2 3 5 7,
> input right the integer 200] for have this
>
> 2 3 5 7{a???{0=?k?a/?0=a|?:???,' is not divisible by ',a????,' is
> divisible by ',k}¨??}200
I don't know what Thunderbird did with the Unicode here; it was alright
earlier.
> 1 is not divisible by 2 3 5 7
> 2 is divisible by 2
I suggested you can save characters (2 or 4?) by trimming those strings,
as there is extra white space here.
Re: BizFuss (was Re: Taming The Switch-Statement)
Author: Rosario19
Date: Sat, 31 Oct 2026 17:14
Date: Sat, 31 Oct 2026 17:14
46 lines
3332 bytes
3332 bytes
On Sat, 31 Oct 2026 13:38:05 +0000, bartc wrote:
>> 1 is not divisible by 2 3 5 7
>> 2 is divisible by 2
>
>I suggested you can save characters (2 or 4?) by trimming those strings,
>as there is extra white space here.
Yes it seems is possible eliminate the extra spaces, and instead of
print in stdout strings, return one table and reduce to 73 the lenght
of the [anonymous] function without input and the name (i call that
function below f)
in codegolf I think there are people tha use specializated language
for codegolf can reduce all this to 10-35 characters max zipping the
strings too.
f{leftarrow}{leftbrace}a{leftarrow}{alpha}{diamond}{commabar}{leftbrace}0={notequalunderbar}k{leftarrow}a/{dieresistilde}0=a{stile}{omega}:{omega},{apostrophe}is
not divisible by{apostrophe},a{diamond}{omega},{apostrophe}is
divisible
by{apostrophe},k{rightbrace}{dieresis}{iota}{omega}{rightbrace}
f„{a„¸ª®{0=?k„a/þ0=a|¾:¾,'is not divisible by',aª¾,'is divisible
by',k}¨¼¾}
2 3 5 f 20
1 is not divisible by 2 3 5
2 is divisible by 2
3 is divisible by 3
4 is divisible by 2
5 is divisible by 5
6 is divisible by 2 3
7 is not divisible by 2 3 5
8 is divisible by 2
9 is divisible by 3
10 is divisible by 2 5
11 is not divisible by 2 3 5
12 is divisible by 2 3
13 is not divisible by 2 3 5
14 is divisible by 2
15 is divisible by 3 5
16 is divisible by 2
17 is not divisible by 2 3 5
18 is divisible by 2 3
19 is not divisible by 2 3 5
20 is divisible by 2 5
Re: Taming The Switch-Statement
Author: Tim Rentsch
Date: Thu, 05 Nov 2026 14:39
Date: Thu, 05 Nov 2026 14:39
47 lines
2947 bytes
2947 bytes
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: > On 2026-10-28 20:02, Tim Rentsch wrote: > >> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: >> >>> On 2026-10-28 00:00, Dan Cross wrote: >>> >>>> In some article, Dan Purgert <dan@djph.net> wrote: >>>> >>>>> On 2026-10-27, Richard Harnden wrote: >>>>> >>>>>> On 27/10/2026 21:25, Chris M. Thomasson wrote: >>>>>> >>>>>>> On 10/27/2026 1:49 PM, fir wrote: >>>>>>> [...] >>>>>>> >>>>>>> I can see it now. Somebody hires you as their graphics guy. >>>>>>> They say go at it. You ask well, where is the AI, you get fired >>>>>>> on the same day? >>>>>> >>>>>> The lazy/incoherent way fir writes ... I can't see his CV getting >>>>>> past the AI vetting stage. >>>>> >>>>> It's okay, he used AI. >>>> >>>> But seriously though why can't he use AI for his spelling and >>>> grammar. >>> >>> Why doesn't he communicate completely and exclusively with an AI >>> instead of posting in newsgroups, spouting gibberish at humans. >>> >>> (An AI appears to be the perfect communication partner for that >>> individual! One could even think that AIs have been developed for >>> exactly this kind of clients in mind.) >>> >>> >>> PS: Related question: Why do some folks here play the role of the >>> AI and continuously feed him. >> >> Why do you make things worse by encouraging further pointless >> discussion? > > [...] My understanding is you have decided not to read my postings so it seems better not to respond further.
Re: Taming The Switch-Statement
Author: Dan Cross
Date: Fri, 06 Nov 2026 12:26
Date: Fri, 06 Nov 2026 12:26
14 lines
1387 bytes
1387 bytes
In article <86a4nnny08.fsf@linuxsc.com>, Tim Rentsch <tr.17687@z991.linuxsc.com> wrote: >Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: >> [...] > >My understanding is you have decided not to read my postings >so it seems better not to respond further. And yet, you just did. Is there some particular reason you feel compelled to make these kinds of posts? If you do not wish to engage further, simply do not respond. - Dan C.
Re: Taming The Switch-Statement
Author: Chris M. Thomasson
Date: Sat, 07 Nov 2026 03:47
Date: Sat, 07 Nov 2026 03:47
35 lines
2647 bytes
2647 bytes
On 10/27/2026 4:39 PM, Janis Papanagnou wrote: > On 2026-10-28 00:00, Dan Cross wrote: >> In article <slrn11e2aa4.2i9.dan@djph.net>, Dan Purgert <dan@djph.net> >> wrote: >>> On 2026-10-27, Richard Harnden wrote: >>>> On 27/10/2026 21:25, Chris M. Thomasson wrote: >>>>> On 10/27/2026 1:49 PM, fir wrote: >>>>> [...] >>>>> >>>>> I can see it now. Somebody hires you as their graphics guy. They >>>>> say go >>>>> at it. You ask well, where is the AI, you get fired on the same day? >>>> >>>> The lazy/incoherent way fir writes ... I can't see his CV getting past >>>> the AI vetting stage. >>> >>> It's okay, he used AI. >> >> But seriously though why can't he use AI for his spelling and >> grammar. > > Why doesn't he communicate completely and exclusively with an AI > instead of posting in newsgroups, spouting gibberish at humans. > > (An AI appears to be the perfect communication partner for that > individual! One could even think that AIs have been developed for > exactly this kind of clients in mind.) > > Janis > > PS: Related question: Why do some folks here play the role of the > AI and continuously feed him. > Beware the assholes that take AI code and say its theirs.
Page 3 of 3 • 125 total messages
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads