Comment detail

アレイのuniq (Nested Flatten)
Squeak Smalltalk の #addIfNotPresent: を使って。
1
2
3
4
5
6
7
| xs uniq |
xs := #(3 1 4 1 5 9 2 6 5 3 5 8 9 7 9).
uniq := OrderedCollection new.
xs do: [:each | uniq addIfNotPresent: each].
^uniq asArray

"=> #(3 1 4 5 9 2 6 8 7) "

Index

Feed

Other

Link

Pathtraq

loading...