More library functions
This commit is contained in:
+7
-2
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user