3

Perl 中有一个非常有用的功能样式列表操作List::Util , List::MoreUtils。Python有类似物吗?我对uniq、reduce、any、allnone特别感兴趣。

提到的模块提供功能:

  • 第一个 max maxstr min minstr 减少 shuffle sum
  • 任何 所有 无 notall tr​​ue false firstidx first_index lastidx last_index insert_after insert_after_string 在 after_incl 之后应用索引 before_incl firstval first_value lastval last_value each_array each_arrayref pairwise natatime mesh zip uniq distinct minmax part
4

1 回答 1

2

您提到的大多数功能已经内置,包括reduce(),any()all().

我对 Perl 不熟悉,但是根据我从您提供的链接中了解到的与Python中的uniqset()等效的内容(如果您想保持原始顺序,list(OrderedDict.fromkeys(mylist))可以是一个解决方案)。

于 2013-04-12T22:38:34.770 回答