Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: =~ doesn't work with Quantum::Superpositions

by Limbic~Region (Chancellor)
on Apr 20, 2003 at 16:30 UTC ( [id://251841]=note: print w/replies, xml ) Need Help??


in reply to =~ doesn't work with Quantum::Superpositions

diotalevi,
I could not find a single example of the binding operator anywhere in the documentation for Quantum::Superpositions. I did however find the following code interesting:

#!/usr/bin/perl use Quantum::Superpositions; $\ = $/; # Create a disjunction of 'a' and 'b'. $dis = any( 'a', 'b' ); print $dis; print "=~: ",$dis =~ /\bb\b/; # true print "eq: ",$dis eq 'b'; # true

I do believe Perl 6's built in any will work with the binding operator. I also took a peak under the hood of the module itself. I could not find a binding operator listed:

q{<} => sub { qblop(swap(@_), sub { $_[0] < $_[1] })}, q{<=>} => sub { qblop(swap(@_), sub { $_[0] <=> $_[1] })}, ... all kinds of other tests q{~} => sub { $_[0]->quop(sub { ~$_[0] })},

Happy hunting!

Cheers - L~R

Update: I guess I spent too long digging around under the hood as Matt beat me to the punch.

Update 2: Chmrr reminded me that ~ is bitwise negation and that the binding operator can't be overloaded - see perldoc overload - Chmrr++

Replies are listed 'Best First'.
Re: Re: =~ doesn't work with Quantum::Superpositions
by theorbtwo (Prior) on Apr 20, 2003 at 18:49 UTC

    As to the perl 6 stuff, BTW, there is a binding operator, :=, but it's nothing like =~; it binds one variable to be an alias of another. =~ is becomming the smart-match operator, ~~, which will do even more then =~, becomming polymorphic on both sides, doing things like array intersection.

    In any case, pretty much all operators are overloadable in perl6. However, smart-match is probably smart enough to call the approprate string-/num-/bool-/etc-rafication overloads, as approprate.


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://251841]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-24 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found