This commit is contained in:
2024-08-09 23:29:28 +03:00
parent b883515a5f
commit 114f32cdc7
13 changed files with 130 additions and 132 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from '@jest/globals';
import { toNative as $$, _, fromNative as __, ___, undef } from '../src/core';
import { toNative as $$, _, fromNative as __, undef, y } from '../src/core';
import { toNOrd as $o, NOrd } from '../src/ord';
import { toBoolean as $b, iif } from '../src/bool';
import { toNumber as $n, toNumber as $nn, Num, Succ, Zero, fromNumber as _n, fromNumber as _nn, cmp as cmpn, eq as eqn, even, gt as ngt, show as nshow, odd, succ, sum } from '../src/num';
@@ -11,7 +11,7 @@ describe('List', () => {
const infinite: List<Num> = iterate(Succ)(Zero);
const _na: (xs: number[]) => List<Num>
= xs => xs.length === 0 ? Nil : Cons(_nn(xs[0]))(___(() => _na(xs.slice(1)).run()));
= xs => xs.length === 0 ? Nil : Cons(_nn(xs[0]))(y(() => _na(xs.slice(1))));
const $na: (xs: List<Num>) => number[]
= xs => $$(xs(__([]))(_(x => _(xs => __([$nn(x), ...$na(xs)])))));
@@ -158,7 +158,7 @@ describe('List', () => {
});
it('handles infinite lists', () => {
const dinfinite: List<Num> = cons(infinite)(___(() => dinfinite.run()));
const dinfinite: List<Num> = cons(infinite)(y(() => dinfinite));
expect($n(concat(dinfinite)(undef)(_(x => _(_xs => x))))).toBe(0);
});
});
+2 -2
View File
@@ -1,12 +1,12 @@
import { describe, expect, it } from '@jest/globals';
import { ___, undef } from '../src/core';
import { undef, y } from '../src/core';
import { toNOrd as $o, NOrd } from '../src/ord';
import { toBoolean as $b, fromBoolean as _b } from '../src/bool';
import { toNumber as $n, Num, Succ, Zero, fromNumber as _n, cmp, div, eq, ge, gt, ifz, le, lt, mod, mul, pred, show, sub, succ, sum } from '../src/num';
import { toString as $s } from '../src/string';
describe('Num', () => {
const infinity: Num = ___(() => Succ(infinity).run());
const infinity: Num = y(() => Succ(infinity));
describe('toNumber', () => {
it('converts 0', () => {
+2 -2
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from '@jest/globals';
import { _, ___, undef } from '../src/core';
import { _, undef, y } from '../src/core';
import { NOrd, toNOrd } from '../src/ord';
import { toBoolean as $b } from '../src/bool';
import { toNumber as $n, Zero, gt as ngt } from '../src/num';
@@ -7,7 +7,7 @@ import { toChar as $c, fromChar as _c } from '../src/char';
import { toString as $s, Cons, Empty, String, fromString as _s, append, cmp, empty, eq, ge, gt, le, len, lt, show, wrap } from '../src/string';
describe('String', () => {
const infinite: String = Cons(_c('a'))(___(() => infinite.run()));
const infinite: String = Cons(_c('a'))(y(() => infinite));
describe('toString', () => {
it('converts ""', () => {