ScriptSpot

Forum topic · General Scripting

Array - Remove redondant values

By Ewok · 2012-04-10

Description

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 (2)

makeUniqueArray

jos · 2012-04-10

You can simply use

makeUniqueArray MyArray
--returns #(1, 2, 3)

Cool!!!Thanks a lot.I had

Ewok · 2012-04-11

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