Author: pmichaud
Date: Sun Nov  9 20:46:53 2008
New Revision: 32477

Modified:
   trunk/languages/perl6/src/classes/Bool.pir

Log:
[rakudo]:  Implementation of Bool.pick (RT #60290, bacek++)
* Patch courtesy Vasily Chekalkin <[EMAIL PROTECTED]>, with minor changes


Modified: trunk/languages/perl6/src/classes/Bool.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Bool.pir  (original)
+++ trunk/languages/perl6/src/classes/Bool.pir  Sun Nov  9 20:46:53 2008
@@ -63,6 +63,25 @@
     self = 0
 .end
 
+=item
+
+Bool.pick - returns True or False
+
+=cut
+
+.sub 'pick' :method
+    .local pmc rand
+    rand = get_hll_global ['Any'], '$!random'
+    $N0 = rand
+    if $N0 < 0.5 goto ret_true
+    $P0 = get_hll_global ['Bool'], 'False'
+    goto done
+  ret_true:
+    $P0 = get_hll_global ['Bool'], 'True'
+  done:
+    .tailcall 'list'($P0)
+.end
+
 
 # Local Variables:
 #   mode: pir

Reply via email to