MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / oneOf

Function oneOf

src/compute-engine/library/random-expression.ts:3–5  ·  view source on GitHub ↗
(xs: T[])

Source from the content-addressed store, hash-verified

1import type { MathJsonExpression, MathJsonSymbol } from '../../math-json.js';
2
3/** A source of uniform numbers in `[0, 1)`: the `entropy` handler of the
4 * host capability registry, supplied by the `RandomExpression` operator. */
5type Draw = () => number;
6
7function oneOf<T = MathJsonExpression>(draw: Draw, xs: T[]): T {
8 return xs[Math.floor(draw() * xs.length)];

Callers 2

randomTrigFunction · 0.85
randomExpressionFunction · 0.85

Calls 1

floorMethod · 0.45

Tested by

no test coverage detected