On Mon, 20 Jan 2020, ToddAndMargo via perl6-users wrote: > Hi All, > > Now what am I doing wrong? > > my $v = 0b00101101 ^ 0b00001001; say $v.base(2); > one(101101, 1001) > > It should be > 100100 >
Please examine the output you get. Does the spurious "one" in there not make you raise an eyebrow and head over to the documentation? ^ is a junction constructor, specifically it creates a one() junction. If you want bitwise XOR use the... bitwise XOR operator +^. In general, the "bare" operators &, |, ^ in Raku are used for declarative purposes: in normal Raku they are junction constructors and in regexes they denote longest-token matching. Many other languages use these operators for (signed or unsigned) bitwise operations, but in Raku these "numeric" bitwise operations are put under the "+" umbrella to show that they are numeric: +&, +| and +^. Corresponding operators also exist for buffers as ~&, ~| and ~^, for booleans as ?&, ?| and ?^ and for sets as (&), (|), (^). This is a truly beautiful and thoughtful thing about Raku. Regards, Tobias -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk