|
1 | | -[js-permutation](http://aureooms.github.io/js-permutation) |
| 1 | +[@aureooms/js-permutation](https://aureooms.github.io/js-permutation) |
2 | 2 | == |
3 | 3 |
|
4 | | -Permutations code bricks for JavaScript. |
| 4 | +<img src="https://upload.wikimedia.org/wikipedia/commons/e/e0/Symmetric_group_3;_Cayley_table;_matrices.svg" width="864"> |
5 | 5 |
|
6 | | -```js |
7 | | -next( reversed( identity( 3 ) ) ) ; // [ 0 , 1 , 2 ] |
8 | | -``` |
9 | | - |
10 | | -[](https://raw.githubusercontent.com/aureooms/js-permutation/master/LICENSE) |
11 | | -[](https://www.npmjs.org/package/aureooms-js-permutation) |
12 | | -[](http://bower.io/search/?q=aureooms-js-permutation) |
13 | | -[](https://travis-ci.org/aureooms/js-permutation) |
14 | | -[](https://coveralls.io/r/aureooms/js-permutation) |
15 | | -[](https://david-dm.org/aureooms/js-permutation#info=dependencies) |
16 | | -[](https://david-dm.org/aureooms/js-permutation#info=devDependencies) |
17 | | -[](https://codeclimate.com/github/aureooms/js-permutation) |
18 | | -[](https://www.npmjs.org/package/aureooms-js-permutation) |
19 | | -[](https://github.com/aureooms/js-permutation/issues) |
20 | | -[](http://inch-ci.org/github/aureooms/js-permutation) |
21 | | - |
22 | | -Can be managed through [jspm](https://github.com/jspm/jspm-cli), |
23 | | -[duo](https://github.com/duojs/duo), |
24 | | -[component](https://github.com/componentjs/component), |
25 | | -[bower](https://github.com/bower/bower), |
26 | | -[ender](https://github.com/ender-js/Ender), |
27 | | -[jam](https://github.com/caolan/jam), |
28 | | -[spm](https://github.com/spmjs/spm), |
29 | | -and [npm](https://github.com/npm/npm). |
30 | | - |
31 | | -## Caveat |
32 | | - |
33 | | -Requires `regeneratorRuntime` to be defined, see |
34 | | -[babel docs](http://babeljs.io/docs/usage/polyfill/). |
35 | | - |
36 | | -## Install |
37 | | - |
38 | | -### jspm |
39 | | -```terminal |
40 | | -jspm install github:aureooms/js-permutation |
41 | | -# or |
42 | | -jspm install npm:aureooms-js-permutation |
43 | | -``` |
44 | | -### duo |
45 | | -No install step needed for duo! |
46 | | - |
47 | | -### component |
48 | | -```terminal |
49 | | -component install aureooms/js-permutation |
50 | | -``` |
| 6 | +Permutation library for JavaScript. |
| 7 | +See [docs](https://aureooms.github.io/js-permutation). |
| 8 | +Parent is [@aureooms/js-algorithms](https://github.com/aureooms/js-algorithms). |
51 | 9 |
|
52 | | -### bower |
53 | | -```terminal |
54 | | -bower install aureooms-js-permutation |
55 | | -``` |
56 | | - |
57 | | -### ender |
58 | | -```terminal |
59 | | -ender add aureooms-js-permutation |
60 | | -``` |
61 | | - |
62 | | -### jam |
63 | | -```terminal |
64 | | -jam install aureooms-js-permutation |
65 | | -``` |
66 | | - |
67 | | -### spm |
68 | | -```terminal |
69 | | -spm install aureooms-js-permutation --save |
70 | | -``` |
71 | | - |
72 | | -### npm |
73 | | -```terminal |
74 | | -npm install aureooms-js-permutation --save |
75 | | -``` |
76 | | - |
77 | | -## Require |
78 | | -### jspm |
79 | 10 | ```js |
80 | | -let permutation = require( "github:aureooms/js-permutation" ) ; |
81 | | -// or |
82 | | -import permutation from 'aureooms-js-permutation' ; |
83 | | -``` |
84 | | -### duo |
85 | | -```js |
86 | | -let permutation = require( "aureooms/js-permutation" ) ; |
87 | | -``` |
88 | | - |
89 | | -### component, ender, spm, npm |
90 | | -```js |
91 | | -let permutation = require( "aureooms-js-permutation" ) ; |
92 | | -``` |
93 | | - |
94 | | -### bower |
95 | | -The script tag exposes the global variable `permutation`. |
96 | | -```html |
97 | | -<script src="bower_components/aureooms-js-permutation/js/dist/permutation.min.js"></script> |
98 | | -``` |
99 | | -Alternatively, you can use any tool mentioned [here](http://bower.io/docs/tools/). |
100 | | - |
101 | | -### jam |
102 | | -```js |
103 | | -require( [ "aureooms-js-permutation" ] , function ( permutation ) { ... } ) ; |
| 11 | +import { next , reversed , identity } from '@aureooms/js-permutation' ; |
| 12 | +next( reversed( identity( 3 ) ) ) ; // [ 0 , 1 , 2 ] |
104 | 13 | ``` |
105 | 14 |
|
106 | | -## Use |
107 | | - |
108 | | -```js |
109 | | -let sigma = permutation.identity( 3 ) ; |
110 | | - |
111 | | -sigma ; // [ 0 , 1 , 2 ] |
112 | | - |
113 | | -permutation.reversed( sigma ) ; // [ 2 , 1 , 0 ] |
114 | | - |
115 | | -permutation.next( sigma ) ; // [ 0 , 2 , 1 ] |
116 | | - |
117 | | -for ( let tau of permutation.permutations( 3 ) ) { |
118 | | - |
119 | | - ... // yields [ 0 , 1 , 2 ] |
120 | | - // [ 0 , 2 , 1 ] |
121 | | - // [ 1 , 0 , 2 ] |
122 | | - // [ 1 , 2 , 0 ] |
123 | | - // [ 2 , 0 , 1 ] |
124 | | - // [ 2 , 1 , 0 ] |
125 | | - |
126 | | -} |
127 | | - |
128 | | -permutation.invert( [ 0 , 1 , 2 ] ) ; // [ 0 , 1 , 2 ] |
129 | | -permutation.invert( [ 0 , 2 , 1 ] ) ; // [ 0 , 2 , 1 ] |
130 | | -permutation.invert( [ 1 , 0 , 2 ] ) ; // [ 1 , 0 , 2 ] |
131 | | -permutation.invert( [ 1 , 2 , 0 ] ) ; // [ 2 , 0 , 1 ] |
132 | | -permutation.invert( [ 2 , 0 , 1 ] ) ; // [ 1 , 2 , 0 ] |
133 | | -permutation.invert( [ 2 , 1 , 0 ] ) ; // [ 2 , 1 , 0 ] |
134 | | - |
135 | | -permutation.compose( "abc" , [ 2 , 0 , 1 ] ) ; // [ "c" , "a" , "b" ] |
136 | | - |
137 | | -permutation.bitreversal( 8 ) ; // [ 0 , 4 , 2 , 6 , 1 , 5 , 3 , 7 ] |
138 | | -``` |
| 15 | +[](https://raw.githubusercontent.com/aureooms/js-permutation/master/LICENSE) |
| 16 | +[](https://www.npmjs.org/package/@aureooms/js-permutation) |
| 17 | +[](https://travis-ci.org/aureooms/js-permutation) |
| 18 | +[](https://coveralls.io/r/aureooms/js-permutation) |
| 19 | +[](https://david-dm.org/aureooms/js-permutation#info=dependencies) |
| 20 | +[](https://david-dm.org/aureooms/js-permutation#info=devDependencies) |
| 21 | +[](https://codeclimate.com/github/aureooms/js-permutation) |
| 22 | +[](https://www.npmjs.org/package/@aureooms/js-permutation) |
| 23 | +[](https://github.com/aureooms/js-permutation/issues) |
| 24 | +[](https://aureooms.github.io/js-permutation/source.html) |
0 commit comments