astl
Version:
AssemblyScript-STL (Standard Template Library, migrated from the C++)
25 lines (22 loc) • 605 B
text/typescript
import { Vector } from "../../container/Vector";
export namespace CMath
{
export function min<T>(x: T, y: T): T
{
return x < y ? x: y;
}
export function max<T>(x: T, y: T): T
{
return x > y ? x : y;
}
export function factorial(k: usize): usize
{
if (FACTORIALS.size() <= k)
for (let i: usize = FACTORIALS.size(); i <= k; ++i)
FACTORIALS.push_back(FACTORIALS.at(i - 1) * i);
return FACTORIALS.at(k);
}
const FACTORIALS: Vector<usize> = new Vector();
}