Home Tutorials Forums Articles Blogs Movies Library Employment Press

 ActionScript.org Forums Find the number of people that can be seen from the treasurer place of view.
 Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

 06-14-2012, 04:19 PM #1 gavra Registered User   Join Date: Jun 2012 Posts: 10 Find the number of people that can be seen from the treasurer place of view. can anyone help me with following behind the treasury there is n people waiting in the row with their height h[1], h[2], h[3]...h[n]. Find the number of people that can be seen from the treasurer place of view. example : heightes are 155,170,165,180,175,195 - the answer is 4 he can see 1st, 2nd,4th, 6th. thank you..
 06-14-2012, 05:44 PM #2 arkitx Senior Member   Join Date: Jan 2011 Posts: 703 ActionScript Code: ```var people:Array = new Array(155,170,165,180,175,195); function countHigher(arr) {     var count = 0;     var tmp;     for (var i = 0; ipeople[i]) ?  count: (tmp=people[i], count++);     }     return count; } trace("Count: "+countHigher(people));``` __________________ Regards arkitx
 06-14-2012, 07:23 PM #3 paulina Senior Member   Join Date: Jan 2010 Posts: 116 Hello! Sorry to interrupt. I have never seen such a function. Can someone please explain.
 06-15-2012, 08:37 PM #4 gavra Registered User   Join Date: Jun 2012 Posts: 10 thanks, but if you have some extra time can you explain to me what actually does " ? " and " : " in this line (tmp>people[i]) ? count: (tmp=people[i], count++); Last edited by gavra; 06-15-2012 at 08:46 PM.
 06-16-2012, 12:20 AM #5 Prid Prid - Outing     Join Date: Oct 2009 Location: Halden, Norway Posts: 1,191 Code: `(condition) ? trueExpression : falseExpression` for example: ActionScript Code: `(5>3) ? trace("yes") : trace("no");` If 5 is greater than 3, if that condition is TRUE, then execute the TRUE expression, which is to the left for " : ", but let's alter the code: ActionScript Code: `(1>3) ? trace("yes") : trace("no");` in this case, 1 is NOT greater than 3, so the FALSE expression will be executed, which is to trace "no". __________________ I have returned, and am now 18
 06-16-2012, 04:27 AM #6 arkitx Senior Member   Join Date: Jan 2011 Posts: 703 Prid explained all which you want to know. Else, this is a shorthand of if..else statement. Thank you Prid __________________ Regards arkitx
 06-16-2012, 01:14 PM #7 Prid Prid - Outing     Join Date: Oct 2009 Location: Halden, Norway Posts: 1,191 np btw, gotta commend you for that great short code __________________ I have returned, and am now 18
 06-16-2012, 02:12 PM #8 gavra Registered User   Join Date: Jun 2012 Posts: 10 I just never used that kind of if statement before. Thanks
 06-16-2012, 02:21 PM #9 Prid Prid - Outing     Join Date: Oct 2009 Location: Halden, Norway Posts: 1,191 @gavra: trust me, when I first saw it, I thought it was some really complex code, but after discovering that it was a common programming syntax, I learned of its simplicity __________________ I have returned, and am now 18
06-16-2012, 05:11 PM   #10
gavra
Registered User

Join Date: Jun 2012
Posts: 10

Quote:
 Originally Posted by Prid @gavra: trust me, when I first saw it, I thought it was some really complex code, but after discovering that it was a common programming syntax, I learned of its simplicity
well said

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home ActionScript Forums Group     ActionScript 3.0     ActionScript 2.0     ActionScript 1.0 (and below)     Simple Stuff (Newbies) Flash General Questions     Flash 10 General Questions     Flash 9 General Questions     Flash 8 General Questions     Other Flash General Questions Flex     Flex 2, 3 & 4     Flex 1 Extensions and Plugins     Components     JSFL - Extending Flash Desktop, Mobile and non-browser Environments     AIR (Apollo)     FlashLite / Portable Devices Development     Projectors and CDs Supporting Technologies     HTML and JavaScript     haXe     Server-Side Scripting     Flash Remoting     Flash Media Server General     Best Practices     Gaming and Game Development     Animation and Effects     Flashants Support Forum Community Boards     General Chat     Just for Kicks Challenges     Detention Flash In Action     Site Check     Cool Sites     Widgets Decommissioned     Projects and Positions CMS Forums     Announcements Board     Content Postings / Updates     Product Review Requests     CMS Technical Questions     Process Questions     Collaboration & Suggested Articles

All times are GMT. The time now is 02:00 PM.

///