Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Checking if all values in a array are the same?

Author
Message
SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 17th Aug 2011 08:15
Say i have an array that has 100 values in it, how would i chack if all the values in it were equal to each other without typing:

if array(1) = array(2)....

Bluespark
15
Years of Service
User Offline
Joined: 18th Mar 2011
Location:
Posted: 17th Aug 2011 09:01
Easy.
SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 17th Aug 2011 09:04
Wow I feel stupid, I guess I shouldn't be coding on just a few hours of sleep xD thanks a bunch!

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Aug 2011 16:24
Or even more compressed:





TheComet

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 17th Aug 2011 17:42
I like that .. they all have to match the first one.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Aug 2011 17:52
Quote: "I like that"


So do I.

Had to think twice when I saw those snippets.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Aug 2011 18:15 Edited at: 17th Aug 2011 18:17
Quote: "Had to think twice when I saw those snippets. "


So I wasn't the only one that thought you had to perform a multi-dimensional check the first time?

TheComet

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Aug 2011 18:20 Edited at: 17th Aug 2011 18:22
With IanMs SORT ARRAY command there's no need to use a FOR/NEXT loop to check every element. We only need to check 2 of them (the first against the last).



If you don't have IanMs Matrix 1 Utilities Plugin already how have you been able to program till now?... with sticks and tape?

Get it here and unleash Darkbasic Pros full potential:
https://forumfiles.thegamecreators.com/download/2192430

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 17th Aug 2011 20:01 Edited at: 17th Aug 2011 20:04
I'll bet that sorting is a for next loop though in C or whatever. I mean, my own sort routines use quite a few loops.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Aug 2011 23:02
Yeah probably but it may be faster than a FOR/NEXT loop in Darkbasic Pro.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Aug 2011 17:17
That needs to be tested - sorting is a more complex task than a single for/next pass so it's not obvious what the trade-off is.

Login to post a reply

Server time is: 2026-07-10 10:19:54
Your offset time is: 2026-07-10 10:19:54