GithubHelp home page GithubHelp logo

hnatiukr / pair-constructor Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 235 KB

A pair, as a compound data constructor for constructed abstractions. TypeScript supported

License: GNU General Public License v3.0

Makefile 16.16% TypeScript 83.84%
data-structure functional-programming javascript library pair pairs sicp typescript compound-data

pair-constructor's Introduction

pair-constructor

npm version Node.js CI License: GNU GPL 3.0

A pair, as a compound data constructor for constructed abstractions. TypeScript supported.

Compound data: pairs

Installation

npm i pair-constructor
yarn add pair-constructor

Usage

See documentation and examples.

Motivation

One of the most critical topics in programming is abstraction. The larger the codebase, the more abstractions are used or created. A significant part of the developer's time is spent modelling the domain and implementing it in code, as well as in its further support and development. As a rule, this issue is not given time at all, but the quality of your code depends on the ability to model, and how easy it will be to work with it and understand and modify it.

The idea of data abstraction is to define for each type of data object a set of basic operations through which all actions with objects of this type will be expressed:

  • it is easier for us to talk about the program because, at the level of abstraction at which we work, we operate with a small limited set of entities, which also correspond to the same level of thinking about them
  • it is easier for us to combine different parts of the program, glueing them together through the interfaces we have defined to obtain new more complex behaviour
  • it is much easier for us to maintain and change our programs, because the code, separated by an abstraction barrier at a certain level, does not depend on implementing lower levels. This allows individual levels to be overwritten at any time, for example for better performance.

A pair is a data structure that is the basis of compound data. Pairs don't exist in JavaScript/TypeScript. The idea is that the constructor creates a pair, and the selectors serve to extract the first value (using car) and the second value (using cdr) from the pair. Pairs are immutable. You can only create a new one based on the previous one.

A pair is only what is created using the cons constructor. If for some reason, not a pair was passed to the selectors, then the result will be just such an error: Argument must be a pair, but it was ${ARG}.

--

CAR and CDR etymology

pair-constructor's People

Contributors

hnatiukr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.