|
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 | + |
| 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). |
5 | 9 |
|
6 | 10 | ```js
|
| 11 | +import { next , reversed , identity } from '@aureooms/js-permutation' ; |
7 | 12 | next( reversed( identity( 3 ) ) ) ; // [ 0 , 1 , 2 ]
|
8 | 13 | ```
|
9 | 14 |
|
10 | 15 | [](https://raw.githubusercontent.com/aureooms/js-permutation/master/LICENSE)
|
11 | 16 | [](https://www.npmjs.org/package/@aureooms/js-permutation)
|
12 |
| -[](http://bower.io/search/?q=@aureooms/js-permutation) |
13 | 17 | [](https://travis-ci.org/aureooms/js-permutation)
|
14 | 18 | [](https://coveralls.io/r/aureooms/js-permutation)
|
15 | 19 | [](https://david-dm.org/aureooms/js-permutation#info=dependencies)
|
16 | 20 | [](https://david-dm.org/aureooms/js-permutation#info=devDependencies)
|
17 | 21 | [](https://codeclimate.com/github/aureooms/js-permutation)
|
18 | 22 | [](https://www.npmjs.org/package/@aureooms/js-permutation)
|
19 | 23 | [](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 |
| -``` |
51 |
| - |
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 |
| -```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 ) { ... } ) ; |
104 |
| -``` |
105 |
| - |
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 |
| -``` |
| 24 | +[](https://aureooms.github.io/js-permutation/source.html) |
0 commit comments