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.

Newcomers AppGameKit Corner / Minimum function

Author
Message
Greenwich
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location:
Posted: 25th Jan 2015 20:28
Is there a minimum and maximum function implemented in AppGameKit tier 1 somewhere?

I'm having a hard time writing one that works nicely. At this point I've resorted to



...etc. It feels like I'm clumsily reinventing a wheel.

It's mean time. *averages*
paulrobson
9
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 25th Jan 2015 22:43
No ; and AppGameKit does not have variable arguments.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Jan 2015 10:11
You can condense the number of functions to just one...

myAnswer# = min(a, b)
myAnswer# = min(a, min(b,c))
myAnswer# = min(a, min(b,min(c,d)))

Quidquid latine dictum sit, altum sonatur
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th Jan 2015 12:59 Edited at: 26th Jan 2015 13:00
Alternatively you could fill an array and pass that into a function that looks for the minimum value from any number of array values:


EDIT: This requires AppGameKit V2 to work!


Using AppGameKit V2 Tier 1
Greenwich
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location:
Posted: 27th Jan 2015 01:31
Thanks, baxslash and BatVink. The solution baxslash proposed is working perfectly for me.

It's mean time. *averages*
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 27th Jan 2015 09:32
I like Baxslash' solution too, it's a good use of the new array.length parameter.

Quidquid latine dictum sit, altum sonatur
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 28th Jan 2015 21:28
Quote: "Alternatively you could ..."

Quote: "The solution baxslash proposed is working perfectly"

Quote: "I like Baxslash' solution too, it's a good use of the new array.length parameter"

Yes, AppGameKit Master he is.


Coding things my way since 1981 -- Currently using AppGameKit V1 Tier 1

Login to post a reply

Server time is: 2024-04-24 02:41:30
Your offset time is: 2024-04-24 02:41:30