ruby remove duplicates from multidimensional array
来源:互联网 发布:4399刷盒币软件 编辑:程序博客网 时间:2024/05/17 12:04
names = ["Bob", "Dave", "Clive"]names2 = names.repeated_combination(2).to_a[["Bob", "Bob"], ["Bob", "Dave"], ["Bob", "Clive"], ["Dave", "Dave"], ["Dave", "Clive"], ["Clive", "Clive"]]
I would do :
names = ["Bob", "Dave", "Clive"]names.combination(2).to_a# => [["Bob", "Dave"], ["Bob", "Clive"], ["Dave", "Clive"]]
and to correct your code :-
non_uniq_comb = names.repeated_combination(2).reject { |a,b| a == b }
0 0
- ruby remove duplicates from multidimensional array
- Remove duplicates from array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates From Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- 堆与堆排序
- Android聊天软件的开发
- 宏的基本用法
- 规范男发给你
- 【Android进阶】如何使用文件来保存程序中的数据
- ruby remove duplicates from multidimensional array
- 调试规则,debugging rules
- ZOJ Monthly, June 2014 月赛BCDEFGH题题解
- windows下用BOSH lite方式在单个VM中安装Cloud Foundry2.x
- poj-1068
- Linux 文件编程的两种不同方式
- 二维数组基本操作
- 行列式求值
- 【文件管理】特殊文件系统/proc