Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Permutate an array by applying a function to its elements.
CoffeeScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
src
test
.gitignore
README.md
package.json

README.md

funcy_perm

Take an array, apply a function to all possible combinations.

Install & Use

Shell:

npm install funcy_perm

CoffeeScript:

funcy_perm = require "funcy_perm"

my_arr = [ 0 , 0 , 0 ]

funcy_perm(my_arr).perm ( val, i ) -> 
  val + 1

// returns
[ 
  [ 0, 0, 0 ],
  [ 0, 0, 1 ],
  [ 0, 1, 0 ],
  [ 0, 1, 1 ], 

  [ 1, 0, 0 ],
  [ 1, 0, 1 ], 
  [ 1, 1, 0 ], 
  [ 1, 1, 1 ]
]

Note

An empty array returns, an array with an empty array. Example:

funcy_perm([]).perm some_func

// returns 
[ [] ]
Something went wrong with that request. Please try again.