Array - Remove redondant values

I'm struggeling with an array containing several times the same values.

MyArray = #(1,2,3,1,2,3,1,2,3)

Does anyone know how to filter the redondant values in order to get:

MyArray = #(1,2,3)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jos's picture

makeUniqueArray

You can simply use

makeUniqueArray MyArray
--returns #(1, 2, 3)
Ewok's picture

Cool!!!Thanks a lot.I had

Cool!!!

Thanks a lot.

I had figured out this workaround:

List = #(1,2,3,4,1,2)
List02 = #()
PreviousValue = #()
 
sort List
for element in List do
(if element != PreviousValue then append List02 element
 PreviousValue = element)

List = List02

But nothing's shorter than 'makeUniqueArray'

Thank you very much.

Ewok

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.