Skip to content

About

No description, website, or topics provided.

Resources

Stars

11 stars

Watchers

6 watching

Forks

Repository files navigation

js-pairs-data

github action status

Зачем это нужно

Список, собранный из пар: каждый элемент это пара «значение и остаток списка». Библиотека нужна курсам, где списки строятся поверх @hexlet/pairs, а не берутся готовыми из языка.

На таком списке видно, откуда берутся head и tail, почему обход рекурсивен и во что обходится доступ к элементу по номеру.

Install

npm install @hexlet/pairs-data

Usage example

import {
  l, isList, toString, cons, filter, head, tail
} from '@hexlet/pairs-data';

const numbers = l(3, 4, 5, 6, 7);
toString(numbers); // (3, 4, 5, 6, 7)

const first = head(numbers); // 3
const rest = tail(numbers);
toString(rest); // (4, 5, 6, 7)

isList(first); // false
isList(rest); // true

const newList = cons(8, rest);
toString(newList); // (8, 4, 5, 6, 7)

const filtered = filter((el) => el < 7, newList);
isList(filtered); // true
toString(filtered); // (4, 5, 6)

For more information, see the Full Documentation


Hexlet Ltd. logo

This repository is created and maintained by the team and the community of Hexlet, an educational project. Read more about Hexlet.

About

No description, website, or topics provided.

Resources

Stars

11 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages