Does Monkey support "Piles"?
Community Forums/Monkey Talk/Does Monkey support "Piles"?| 
 | ||
| Piles, such as in PHP, allow for selection of X random entities from an array.  For example, select 3 cards from the deck of cards (the pile).  I know I can do this with Classes and a field for Eligibility or something of the sort, but didn't know if there was a quicker way to accomplish this in Monkey. Thanks! | 
| 
 | ||
| try the demo it sounds as if "Stack" is What you are looking for. | 
| 
 | ||
| *Dabz reads thread title... The temptation is immense... Can... He... Just... Hold.. On... Long... Enough... To... Click... The Bac* No, but I'd recommend a cushion or an inflatable swim ring! AHHHHHHHHHHHH Dabz | 
| 
 | ||
| It's easy enough to write your own random selection code. For example with an array of 52 cards. ' This is pseudo code to pick 3 cards numbered 1 to 52. For k = 1 to 3 Let n be a random integer from k to 52. Swap card k and card n. Next Now the first three cards are the randomly selected ones, cards 4 to 52 are still unused. | 
| 
 | ||
| @jasonmiceli why do you ask? would that be the determining factor to decide if you are going to buy/use monkey or not? That would be a really weak reason. | 
| 
 | ||
| Agreed. You don't need a built in "stack class" to make a fifo or standard lifo stack anyway. Just make a class with an "intelligent" array or list. Last edited 2011 | 
| 
 | ||
| @Dabz: Anusol, mate. Trust me. Er.. or so I've been told. | 
| 
 | ||
| Linked lists can provide this functionality as pile and as stack with LIFO and LILO functinoality. And there are linked lists on Monkey. So yeas, there are stacks. | 
| 
 | ||
| Floyd - certainly that's a workable approach - thanks! Jesse - no, not a determining factor at all. I just saw another project similar to the one I'm working on that was written in PHP with Piles, and was curious if there was similar functionality here. Thanks all - I have a couple possible approaches now! |