New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Bool.pick in Rakudo #384
Comments
From @masak...or, if easier, .pick on all enum types. Rakudo r32267 recognizes 'Bool.pick' as a valid program, but hangs |
From @masakCarl (>):
Found and fixed the hanging problem in r32280, with the help of jonathan++. The core issue of this ticket still remains, though: to implement |
@masak - Status changed from 'new' to 'open' |
From @bacekOn Sun Nov 02 03:43:27 2008, masak wrote:
Ad-hoc implementation attached. I still trying to implement Enum.pick. -- |
From @bacekbool_pick.patchdiff --git a/languages/perl6/src/classes/Bool.pir b/languages/perl6/src/classes/Bool.pir
index bcdcffb..6fd8ce8 100644
--- a/languages/perl6/src/classes/Bool.pir
+++ b/languages/perl6/src/classes/Bool.pir
@@ -63,6 +63,24 @@ This is a value type, so just returns itself.
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'
+ .return($P0)
+ ret_true:
+ $P0 = get_hll_global ['Bool'], 'True'
+ .return($P0)
+.end
+
# Local Variables:
# mode: pir
|
From @pmichaudOn Sat, Nov 08, 2008 at 07:35:57PM -0800, Vasily Chekalkin via RT wrote:
Note that according to the current S29, .pick returns a List. Pm |
From @pmichaudApplied (with minor improvements) in r32477, thanks! Pm |
1 similar comment
From @pmichaudApplied (with minor improvements) in r32477, thanks! Pm |
@pmichaud - Status changed from 'open' to 'resolved' |
From @bacekPatrick R. Michaud wrote:
Ah, ok. Revised patch attached. -- |
From @bacekbool_pick2.patchcommit da5c54927e251a7f99045c9b5c1f60faa4e29dd4
Author: Vasily Chekalkin <bacek@haste.optusnet.com.au>
Date: Mon Nov 10 13:03:11 2008 +1100
Bool.pick
diff --git a/languages/perl6/src/classes/Bool.pir b/languages/perl6/src/classes/Bool.pir
index 129466a..44c2b37 100644
--- a/languages/perl6/src/classes/Bool.pir
+++ b/languages/perl6/src/classes/Bool.pir
@@ -52,6 +52,29 @@ symbols for C<Bool::True> and C<Bool::False>.
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:
+ .local pmc result
+ result = 'list'()
+ push result, $P0
+ .return(result)
+.end
+
# Local Variables:
# mode: pir
|
Migrated from rt.perl.org#60290 (status was 'resolved')
Searchable as RT60290$
The text was updated successfully, but these errors were encountered: