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
--- PyGate Linux v1.5.19
* Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)