More library functions

This commit is contained in:
Freywar Ulvnaudgari
2024-08-07 14:50:56 +03:00
parent a0c6f3d9a2
commit 7a9ef2a7d0
4 changed files with 38 additions and 6 deletions
+7 -2
View File
@@ -31,8 +31,13 @@ export const append: L<<T extends P>(l: List<T>) => L<(r: List<T>) => List<T>>>
export const concat: L<<T extends P>(ls: List<List<T>>) => List<T>>
= _(ls => ls._(Nil)._(_(x => _(xs => append._(x)._(concat._(xs))))));
export const repeat: L<<T extends P>(v: T) => List<T>>
= _(v => cons._(v)._(repeat._(v)));
export const repeat: L<<T extends P>(x: T) => List<T>>
= _(x => cons._(x)._(repeat._(x)));
export const iterate: L<<T extends P>(f: L<(x: T) => T>) => L<(x: T) => List<T>>>
= _(<T extends P>(f: L<(x: T) => T>) =>
_((x: T) =>
cons._(x)._(iterate._(f)._(f._(x)))));
export const head: L<<T extends P>(xs: List<T>) => T>
= _(xs => xs._(undef)._(_(x => _(_xs => x))));
+1 -1
View File
@@ -7,7 +7,7 @@ import { Cons, List, Nil, cmp as cmpl, concat, cons, eq as eql, ge as gel, gt as
export type String = List<Char>;
export { Nil as Empty, nul as empty, len, Cons, cons, snoc, append, get, update, set } from './list';
export { Nil as Empty, nul as empty, len, Cons, cons, snoc, append, repeat, iterate, get, update, set } from './list';
export const cmp: L<(l: String) => L<(r: String) => Ord>>
= cmpl._(cmpc);