Article View: comp.lang.c
Article #1212Re: variadic min and max, (any some and none, cat and more)
From: fir
Date: Sat, 31 Oct 2026 17:53
Date: Sat, 31 Oct 2026 17:53
57 lines
2898 bytes
2898 bytes
Rosario19 pisze:
> On Sun, 25 Oct 2026 04:24:26 +0000, Richard Harnden wrote:
>> On 23/10/2026 06:44, fir wrote:
>>> when thinkong on variadic functions not much come to mind but
>>> only recently i noticed min or max would be good for variadic
>>>
>>> the ai wrote me such variadic min
>>
>> I don't think that I'd bother with stdarg at all.
>>
>> Just use a string of ints ...
>>
>> int min(const int *n)
>> {
>> int m = INT_MAX;
>>
>> while ( *n )
>> {
>> if ( *n < m ) m = *n;
>>
>> n++;
>> }
>>
>> return m;
>> }
>>
>>> int a=Min(4,10,3,7,-2); // -2
>>
>> int a = min((int[]){10,3,7,-2}));
>
> in this way can not be used 0, in the 0 terminated list of integers...
>
> I think would be better opertate in the INT_MAX terminate list of
> integers (so the range would be INT_MIN..(INT_MAX-1)):
>
> int min(int *n)
> {int m=INT_MAX;
>
> while ( *n!=INT_MAX )
> {if ( *n < m ) m = *n;
> n++;
> }
> return m;
> }
>
> this would be better because allow to use 0 too at cost to not use the
> INT_MAX value
>
thats quite good remark..interestingly i didnt thought of that thing
(maybe becouse i nevef needed that, coz i dont much lik ethose
things that have mark of end, but if some ould do indeed the value_max
is imo better to use
vaguelly i remember writing in commodore 64 assembly could have some
convention (FF or FFFF) but i dont exactly remember
Technical Details
Message-ID:
<11c59u7$1alos$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11bes8b$1gncr$1@dont-email.me> <11bk09r$3acgl$1@dont-email.me> <i06cel5b0c5rllrhc4cc1c8gld5ovgvj6u@4ax.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: fir <profesor.fir@gmail.com> Newsgroups: comp.lang.c Subject: Re: variadic min and max, (any some and none, cat and more) Date: Sat, 31 Oct 2026 18:53:09 +0100 Organization: A noiseless patient Spider Lines: 57 Message-ID: <11c59u7$1alos$1@dont-email.me> References: <11bes8b$1gncr$1@dont-email.me> <11bk09r$3acgl$1@dont-email.me> <i06cel5b0c5rllrhc4cc1c8gld5ovgvj6u@4ax.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 31 Oct 2026 17:53:12 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1398556"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dXIkRbg+llD5VxaHzH4Xb6PRuI1wPZvE="; posting-host="3c0fe0580cd29671e73f11f7cf42b8a2" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0 SeaMonkey/2.53.24 Cancel-Lock: sha1:VVBuFy7CgaiInIGIzCJSHxzz35c= sha256:nrnhYNzZQlqtebl4sjTB2Kdxb7N5ruwcAhWRI2EbHvc= sha1:fSBUnFhMInLmAikZS571Y/haSkY= sha256:gWU8z+lT/4J+sNg9mS/yf1NqGS7u+jxGDm8zjWTvEdc= In-Reply-To: <i06cel5b0c5rllrhc4cc1c8gld5ovgvj6u@4ax.com>