提供需要穷举的内容之后输出所有结果
|
1
没用过 js ,不过貌似 array 有 map 方法?
没太明白你想干什么。 |
|
learnshareJul 4, 2016
3
@isbase 自己写咯
|
|
ljbha007Jul 4, 2016
4
1,2,3,4].forEach(function(i){console.log(i)})
|
|
ljbha007Jul 4, 2016
5
[1,2,3,4].forEach(function(i){console.log(i)})
|
|
6
用 underscore 也可以
_.map([1,2,3,4], function(i){console.log(i)}) |
|
7
就一行代码的事而已,哪里那么复杂……
var a = [1,2,3,4]; var b = ['a','b','c','d']; var c = a.map((a_i) => b.map((b_i) => ([a_i, b_i]))).reduce((l, r) => r.concat(l)); |
|
bramblexJul 4, 2016
9
javaScript 不提供 concatMap 真蛋疼……
|
|
10
ES6 还有 Map, WeakMap, Iterator, for...of...
|
|
11
@isbase lz 要的是全排列函数还是只是要输出 1a , 2a...1b, 2b 这样的东西?
如果是全排列,原生 js 应该是没有这样的排列函数的,不过网上算法很多,另外提个建议,算法写出来后不要企图将结果写入一个文件(针对 26 字母+10 数字)… 如果是后面的,随便写个 for 循环就好了吧 =。= |
|
12
楼主需要的是排列组合的库 js-combinatorics
https://github.com/dankogai/js-combinatorics |
|
SourceManJul 4, 2016
13
别人封装好的库算不算现成的?
|
|
noe132Jul 4, 2016 via Android
14
Array 有 reduce 方法啊
|