# New Ticket Created by Christopher Pruden # Please include the string: [perl #49085] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=49085 >
I've put together a patch to add a 'pick' method to the perl6 compiler's List class. This is mainly cargo-culted from the Junction pick method, with a few changes to bring it inline with the pugs pick method. I'm new to this PIR thing, so please bear with me. Critiques welcome. It's likely that I've not done this in the best way, as well, I'm not sure what tradeoffs there are between using register variables or named variables. Now that that's out of the way, I've implemented two private methods -- pick_no_replacement and pick_replacement -- as well as pick itself, which decides which to call based on the :repl flag. It seems that it's not able to parse the :repl flag right now, so that one isn't really tested -- however, it's the code that I wrote first and it behaved as it should. The algorithm for making the picks without replacement is based on storing the indexes in the array where a particular element was chosen -- if this isn't the best way to do it, please let me know -- it may be just the first naive one I thought of, and, well, the pugs one is rather beyond my ability to read haskell. pick.t is a test file from pugs with a few extra tests thrown in. I've endeavored to keep the same behavior as the pugs pick method. Once again, criticism is more than welcome -- this is the first thing bigger than hello world that I've done in PIR. Thanks for your consideration, Chris Pruden
list_pick.patch
Description: Binary data
pick.t
Description: Binary data