Skip to content

Commit

Permalink
📚 docs(README): Add examples block.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Apr 27, 2021
1 parent 46fca74 commit 8a09d9d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ See [docs](https://set-theory.github.io/cartesian-product/index.html).
> `regeneratorRuntime` to be defined, for instance by importing
> [regenerator-runtime/runtime](https://www.npmjs.com/package/regenerator-runtime).
```js
import { product } from '@set-theory/cartesian-product' ;
product( [ "ABCD" , "xy" ] , 1 ) ; // Ax Ay Bx By Cx Cy Dx Dy

import { range } from '@aureooms/js-itertools' ;
product( [ range( 2 ) ] , 3 ) ; // 000 001 010 011 100 101 110 111

product( [ range( 4 ) , range( 4 ) ] ) ; // 00 01 02 03 10 11 12 13 20 21 ...

import { diagonal } from '@set-theory/cartesian-product' ;
diagonal( range( 4 ) , range( 4 ) ) ; // 00 01 10 02 11 20 03 12 21 30 ...

import { count } from '@aureooms/js-itertools' ;
product( [count( ), count( )] ) ; // Loops forever without yielding. DO NOT DO THIS
diagonal( count( ), count( ) ) ; // 00 01 10 02 11 20 03 12 21 30 ...
import { _product } from '@set-theory/cartesian-product' ;
_product( [count( ), count( )], 0, 2 ) ; // 00 01 02 03 04 05 06 07 08 09 ...
```

[![License](https://img.shields.io/github/license/set-theory/cartesian-product.svg)](https://raw.githubusercontent.com/set-theory/cartesian-product/main/LICENSE)
[![Version](https://img.shields.io/npm/v/@set-theory/cartesian-product.svg)](https://www.npmjs.org/package/@set-theory/cartesian-product)
[![Tests](https://img.shields.io/github/workflow/status/set-theory/cartesian-product/ci:test?event=push&label=tests)](https://github.com/set-theory/cartesian-product/actions/workflows/ci:test.yml?query=branch:main)
Expand Down

0 comments on commit 8a09d9d

Please sign in to comment.