Valnurat Posted April 15, 2018 Posted April 15, 2018 Hi Small question. I trying to find all index in an array with value higher than 7. How can that be possible? Yours sincerely Kenneth.
abberration Posted April 15, 2018 Posted April 15, 2018 This is one way you could do it: #include <array.au3> Dim $array[10] = ["6", "8", "1", "5", "9", "5", "7", "10", "1", "8"] $index = @CRLF For $i = 0 To 9 If $array[$i] > 7 Then $index = $index & $i & @CRLF EndIf Next MsgBox(0, "", "Numbers higher than 7 are at array positions: " & $index) Easy MP3 | Software Installer | Password Manager
Subz Posted April 15, 2018 Posted April 15, 2018 Not the greatest with RegExp but this should do what you want. #include <Array.au3> Local $aArray[20] = [10, 2, 30, 4, 50, 6, 70, 8, 90, 10, 110, 2, 130, 4, 150, 6, 170, 8, 190, 10] Local $aFindAll = _ArrayFindAll($aArray, "\b(7|8|9|[0-9]\d+|(?!0)\d{3,})\b", 0, 0, 0, 3) _ArrayDisplay($aFindAll) _ArrayDisplay($aArray)
bernd670 Posted April 15, 2018 Posted April 15, 2018 Hello, If there are negative numbers or numbers with leading zeros, that's better. #include <Array.au3> Local $aArray[20] = ["-010", "02", "0030", 4, 50, 6, 70, "-08", -90, 7, 110, 2, 130, 4, 150, 6, 170, -8, 190, 10] Local $aFindAll = _ArrayFindAll($aArray, "\b(?<!-)(0*)(8|9|(?!0)\d{2,})\b", 0, 0, 0, 3) _ArrayDisplay($aFindAll) _ArrayDisplay($aArray) greetingsbernd I hacked 127.0.0.1 ->
iamtheky Posted April 15, 2018 Posted April 15, 2018 back to fun loops #include <Array.au3> Local $aArray[20] = ["-010", "02", "0030", 4, 50, 6, 8, "-08", -90, 7, "00010", 2, 130, 4, 9, 6, 170, -8, 190, 10] If number($aArray[_ArrayMinIndex($aArray , 1)]) < 8 Then do _ArrayDelete($aArray , _ArrayMinIndex($aArray , 1)) until number($aArray[_ArrayMinIndex($aArray , 1)]) > 7 EndIf _ArrayDisplay($aArray) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now