Closed mlhaufe closed 1 year ago
Current approach on fibonacci and similar function require an undefined dataDecl and the use of [all]:
undefined
[all]
const fib = Trait(undefined, { [all]: (n) => n == 0 ? 0 : n == 1 ? 1 : fib(n-1) + fib(n-2) })
Allowing primitives and resolving #34 would enable the following:
const fib = Trait(Number, { 0: () => 0, 1: () => 1, _: (n) => fib(n-1) + fib(n-2) })
Primitives to support:
Trait(Number, { 1: () => {}, [Infinity]: () => {}, [Number.EPSILON]: () => {}, [Number.MAX_SAFE_INTEGER]: () => {}, [Number.MAX_VALUE]: () => {}, [Number.MIN_VALUE]: () => {}, [Number.NaN]: () => {}, [NaN]: () => {}, [Number.POSITIVE_INFINITY]: () => {}, [Number.NEGATIVE_INFINITY]: () => {}, }) Trait(Boolean, { false: () => {}, true: () => {} }) Trait(BigInt, { [2n]: () => {} }) Trait(String, { 'arbitrary string': () => {} })
Current approach on fibonacci and similar function require an
undefined
dataDecl and the use of[all]
:Allowing primitives and resolving #34 would enable the following:
Primitives to support: