I apologize, this is plain old C, not Cocoa-specific question, but the
fastest way to get the answer.
I want to create a function that finds the minimum out of a
variable-length list of simple float arguments. In other words, I want
this function:
float min(float x, ...);
Can anyone suggest the implementation?
Do you really need an arbitrary length argument array? Or would
three or four or five be sufficient? Are you overgeneralizing what
would be a relatively easy problem?
inline float min( float a1, float a2, float a3 )
{ return fminf( a1, fminf( a2, a3 ) ); }
inline float min( float a1, float a2, float a3, float a4 )
{ return fminf( a1, min( a2, a3, a4 ) ); }
inline float min( float a1, float a2, float a3, float a4, float a5 )
{ return fminf( a1, min( a2, a3, a4, a5 ) ); }
etc
Enjoy,
Peter.
--
Keyboard Maestro 3 Now Available!
Now With Status Menu triggers!
Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/> <http://download.stairways.com/>
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]