Felicitas Posted October 19, 2021 Share Posted October 19, 2021 Hello again, i have an array like this aArray = -7, -4, 0, 1, 6, 8 I want to find the lowest number except the negative ones an zero (should be 1) Any good idea? Thank you so much Link to comment Share on other sites More sharing options...
TheDcoder Posted October 19, 2021 Share Posted October 19, 2021 Just loop through it and keep track of the lower number you have encountered till now. I don't think there is a more efficient way to do it without the array being sorted. EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Zedna Posted October 19, 2021 Share Posted October 19, 2021 (edited) Look at _ArrayMin() EDIT: Sorry I overlooked needed condition for zero/negative numbers, so as TheDCoder said ... here example from helpfile: #include <Array.au3> Local $avArray = StringSplit("4,2,06,8,12,5", ",") MsgBox(0,'Min String value', _ArrayMin($avArray, 0, 1)) MsgBox(0,'Min Numeric value', _ArrayMin($avArray, 1, 0)) Edited October 19, 2021 by Zedna TheDcoder 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
mikell Posted October 19, 2021 Share Posted October 19, 2021 ? #include <Array.au3> Local $avArray = StringSplit("-7,-4,0,1,6,8", ",", 2) For $i = UBound($avArray) -1 to 0 step -1 If $avArray[$i] = 0 Then _ArrayDelete($avArray, $i) $avArray[$i] = Abs($avArray[$i]) Next ;_ArrayDisplay($avArray) MsgBox(0,'Min Numeric value', _ArrayMin($avArray, 1, 0)) Link to comment Share on other sites More sharing options...
Felicitas Posted October 20, 2021 Author Share Posted October 20, 2021 Thank you so much! It works for me with this code: local $FindGreaterO =_ArrayExtract($new,-1,-1,4,4) For $i = 0 To UBound($FindGreaterO)-1 Step 1 $FindGreaterO[$i] = StringReplace($FindGreaterO[$i],",",".") $FindGreaterO[$i] = Number($FindGreaterO[$i]) Next For $i = UBound($FindGreaterO) -1 to 0 step -1 If $FindGreaterO[$i] <= 0.01 Then _ArrayDelete($FindGreaterO, $i) Next $FindNull=StringReplace(_ArrayMin($FindGreaterO),".",",") ConsoleWrite($FindGreaterO) Link to comment Share on other sites More sharing options...
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