mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Math max/min now take multiple arguments.
This commit is contained in:
@@ -202,13 +202,35 @@ macro log10(x) = $$log10(x);
|
||||
* @require types::is_numerical($typeof(x)) `The input must be a floating point value or float vector`
|
||||
* @require types::is_same($typeof(x), $typeof(y)) `The input types must be equal`
|
||||
**/
|
||||
macro max(x, y) = $$max(x, y);
|
||||
macro max(x, y, ...)
|
||||
{
|
||||
$if ($vacount == 0):
|
||||
return $$max(x, y);
|
||||
$else:
|
||||
var m = $$max(x, y);
|
||||
$for (var $i = 0; $i < $vacount; $i++):
|
||||
m = $$max(m, $vaarg($i));
|
||||
$endfor;
|
||||
return m;
|
||||
$endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* @require types::is_numerical($typeof(x)) `The input must be a numerical value or numerical vector`
|
||||
* @require types::is_same($typeof(x), $typeof(y)) `The input types must be equal`
|
||||
**/
|
||||
macro min(x, y) = $$min(x, y);
|
||||
macro min(x, y, ...)
|
||||
{
|
||||
$if ($vacount == 0):
|
||||
return $$min(x, y);
|
||||
$else:
|
||||
var m = $$min(x, y);
|
||||
$for (var $i = 0; $i < $vacount; $i++):
|
||||
m = $$min(m, $vaarg($i));
|
||||
$endfor;
|
||||
return m;
|
||||
$endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* @require types::@is_float(a) `The input must be a floating point value`
|
||||
|
||||
Reference in New Issue
Block a user