Fill an array with unique elements

Not sure about efficiency but this what i would do (first try)

    RemoveDuplicates(InArray:[]int) : []int =
        var MapSet : [int]logic = map{}

        OutArray := for:
            Value : InArray
            not MapSet[Value]?
            set MapSet[Value] = true
        do:
            Value

Then you use it like this:

        InArray := array{1,2,3,3,3,4,5,5,5,1}
        OutArray := RemoveDuplicates(InArray)
    
        for (Value : OutArray) { Print("{Value}") }
2 Likes