invert-permutation
Advanced tools
Comparing version 0.0.0 to 0.1.0
"use strict" | ||
function invertPermutation(pi) { | ||
var result = new Array(pi.length) | ||
function invertPermutation(pi, result) { | ||
result = result || new Array(pi.length) | ||
for(var i=0; i<pi.length; ++i) { | ||
@@ -6,0 +6,0 @@ result[pi[i]] = i |
{ | ||
"name": "invert-permutation", | ||
"version": "0.0.0", | ||
"version": "0.1.0", | ||
"description": "Inverts permutations", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,17 +5,28 @@ invert-permutation | ||
Usage | ||
===== | ||
First, install using npm: | ||
Example | ||
======== | ||
```javascript | ||
console.log( require("invert-permutation")([1,3,0,2]) ) | ||
//Prints: | ||
// [ 2, 1, 3, 0 ] | ||
``` | ||
# Install | ||
npm install invert-permutation | ||
Then, you can use it as follows: | ||
console.log( require("invert-permutation")([1,3,0,2]) ) | ||
//Prints: | ||
// [ 2, 1, 3, 0 ] | ||
# API | ||
## `require("invert-permutation")(perm[, result]) | ||
Inverts a permutation | ||
* `perm` is the permutation to invert | ||
* `result` is an optional array that gets the result of inverting the permutation | ||
**Returns** `result` or a newly allocated array if nothing is specified | ||
Credits | ||
======= | ||
(c) 2013 Mikola Lysenko. MIT License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3194
6
31