import type { StackContext } from "./api.js" ; import { defOp1 , defOp2 } from "./ops.js" ; import { swap } from "./stack.js" ; import { defWord } from "./word.js" ; param ctx export const add = defOp2 ( ( b , a ) => a + b ) ; param ctx export const mul = defOp2 ( ( b , a ) => a * b ) ; param ctx export const sub = defOp2 ( ( b , a ) => a - b ) ; param ctx export const div = defOp2 ( ( b , a ) => a / b ) ; param ctx export const oneover = defWord ( [ 1 , swap , div ] ) ; param ctx export const mod = defOp2 ( ( b , a ) => a % b ) ; param ctx export const min = defOp2 ( Math . min ) ; param ctx export const max = defOp2 ( Math . max ) ; param ctx export const neg = defOp1 ( ( x ) => - x ) ; param ctx export const pow = defOp2 ( ( b , a ) => Math . pow ( a , b ) ) ; param ctx export const sqrt = defOp1 ( Math . sqrt ) ; param ctx export const exp = defOp1 ( Math . exp ) ; param ctx export const log = defOp1 ( Math . log ) ; param ctx export const sin = defOp1 ( Math . sin ) ; param ctx export const cos = defOp1 ( Math . cos ) ; param ctx export const tan = defOp1 ( Math . tan ) ; param ctx export const tanh = defOp1 ( Math . tanh ) ; param ctx export const floor = defOp1 ( Math . floor ) ; param ctx export const ceil = defOp1 ( Math . ceil ) ; param ctx export const hypot = defOp2 ( Math . hypot ) ; param ctx export const atan2 = defOp2 ( Math . atan2 ) ; param ctx export const rand = ( ctx ) => ( ctx [ 0 ] . push ( Math . random ( ) ) , ctx ) ; param ctx export const even = defOp1 ( ( x ) => ! ( x & 1 ) ) ; param ctx export const odd = defOp1 ( ( x ) => ! ! ( x & 1 ) ) ;