Jump to content

remove duplicated items from Array !!!


Recommended Posts

hello everybody

I have array like this :

#include <Array.au3>

Local $aArray_Base[8] = ["1","2","3","1","2","2","5","6"]

_ArrayDisplay($aArray_Base, "Base array")

how can I remove duplicated items and set the new size of the Array ??

$aArray_Base[5] = ["1","2","3","5","6"]

thanks

Link to comment
Share on other sites

#include <Array.au3>

Local $aArray_Base[8] = ["1","2","3","1","2","2","5","6"]

_ArrayDisplay($aArray_Base, "Base array")
$aArray_Base=_ArrayUnique($aArray_Base,0,0,0,0)
_ArraySort($aArray_Base)
_ArrayDisplay($aArray_Base, "Final array")
Edit: removed item count in _arrayunique()

Edited by Exit

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

#include <Array.au3>

Local $aArray_Base[8] = ["1","2","3","1","2","2","5","6"]

For $i = ubound($aArray_Base) - 1 to 1 step -1
    For $k = $i - 1 to 0 step - 1
        If $aArray_Base[$k] = $aArray_Base[$i] Then
            _ArrayDelete($aArray_Base , $k)
            $i -= 1
        EndIf
    Next
Next

_ArrayDisplay($aArray_Base)

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

#include <Array.au3>

Local $aArray_Base[8] = ["1","2","3","1","2","2","5","6"]

_ArrayDisplay($aArray_Base, "Base array")
$aArray_Base=_ArrayUnique($aArray_Base,0,0,0,0)
_ArraySort($aArray_Base)
_ArrayDisplay($aArray_Base, "Final array")
Edit: removed item count in _arrayunique()

 

thanks so much it works well

and thanks for all ^_^

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...