reorganize directory and file structure
This commit is contained in:
parent
1d826ea8d4
commit
48390b8556
99 changed files with 1155 additions and 1629 deletions
16
lib/structures/list.js
Normal file
16
lib/structures/list.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// 'normal' implementation
|
||||
export const emptyList = [];
|
||||
// const emptyListType = makeGeneric(a => lsType(() => a));
|
||||
export const get = ls => i => ls[i];
|
||||
export const put = ls => i => elem => ls.with(Number(i), elem);
|
||||
export const push = ls => elem => ls.concat([elem]);
|
||||
export const pop = ls => ls.pop();
|
||||
export const map = ls => fn => ls.map(elem => fn(elem));
|
||||
export const length = ls => ls.length;
|
||||
export const fold = ls => callback => initial => {
|
||||
let acc = initial;
|
||||
for (let i=0; i<ls.length; i++) {
|
||||
acc = callback(acc)(ls[i]);
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue