Native syntax

This commit is contained in:
2024-08-27 21:31:59 +03:00
parent c421f4123d
commit b8390cda26
23 changed files with 339 additions and 392 deletions
+7 -7
View File
@@ -16,7 +16,7 @@ describe('List', () => {
const _na: (xs: number[]) => Term = xs => !xs.length ? Nil : Cons._(_n(xs[0]))._(_(() => _na(xs.slice(1))));
const $na: (xs: Term) => number[] = xs => $(xs._(_([]))._(_l(x => _l(xs => _(({ x, xs }) => _([$n(x), ...$na(xs)]))))));
const $na: (xs: Term) => number[] = xs => $(xs._(_([]))._(x => xs => _(({ x, xs }) => _([$n(x), ...$na(xs)]))));
describe('toArray', () => {
it('converts []', () => {
@@ -60,7 +60,7 @@ describe('List', () => {
});
it('handles infinite lists', () => {
expect($n(cons._(_n(0))._(infinite)._(undef)._(_l(x => _l(_ => x))))).toBe(0);
expect($n(cons._(_n(0))._(infinite)._(undef)._(x => _ => x))).toBe(0);
});
});
@@ -78,7 +78,7 @@ describe('List', () => {
});
it('handles infinite lists', () => {
expect($n(snoc._(infinite)._(_n(0))._(undef)._(_l(x => _l(_ => x))))).toBe(0);
expect($n(snoc._(infinite)._(_n(0))._(undef)._(x => _ => x))).toBe(0);
});
});
@@ -142,7 +142,7 @@ describe('List', () => {
});
it('handles infinite lists', () => {
expect($n(append._(infinite)._(infinite)._(undef)._(_l(x => _l(_ => x))))).toBe(0);
expect($n(append._(infinite)._(infinite)._(undef)._(x => _ => x))).toBe(0);
});
});
@@ -161,7 +161,7 @@ describe('List', () => {
it('handles infinite lists', () => {
const dinfinite: Term = g('dinfinite', _(() => cons._(infinite)._(dinfinite)));
expect($n(concat._(dinfinite)._(undef)._(_l(x => _l(_ => x))))).toBe(0);
expect($n(concat._(dinfinite)._(undef)._(x => _ => x))).toBe(0);
});
});
@@ -263,7 +263,7 @@ describe('List', () => {
it('handles infinite lists', () => {
expect($n(
foldr
._(_l(x => _l(a => sum._(x)._(iif._(eqn._(_n(5))._(x))._(Zero)._(a)))))
._(x => a => sum._(x)._(iif._(eqn._(_n(5))._(x))._(Zero)._(a)))
._(Zero)
._(infinite)))
.toBe(15);
@@ -286,7 +286,7 @@ describe('List', () => {
it.failing('handles infinite lists', () => {
expect($n(
foldrz
._(_l(x => _l(a => sum._(x)._(iif._(eqn._(_n(5))._(x))._(Zero)._(a)))))
._(x => a => sum._(x)._(iif._(eqn._(_n(5))._(x))._(Zero)._(a)))
._(infinite)))
.toBe(15);
});
+2 -2
View File
@@ -108,7 +108,7 @@ describe('String', () => {
});
it('handles infinite strings', () => {
expect($c(append._(infinite)._(infinite)._(undef)._(_l(x => _l(_ => x))))).toBe('a');
expect($c(append._(infinite)._(infinite)._(undef)._(x => _ => x))).toBe('a');
});
});
@@ -122,7 +122,7 @@ describe('String', () => {
});
it('handles infinite strings', () => {
expect($c(wrap._(infinite)._(infinite)._(undef)._(_l(x => _l(_ => x))))).toBe('a');
expect($c(wrap._(infinite)._(infinite)._(undef)._(x => _ => x))).toBe('a');
});
});