Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Secret Perl Operators: the boolean list squash operator, x!!

by CountZero (Bishop)
on Jul 31, 2006 at 16:42 UTC ( #564796=note: print w/replies, xml ) Need Help??


in reply to Secret Perl Operators: the boolean list squash operator, x!!

That's really neat: ++

Now we have to find a catchy name for it "Aristotelian Exclamations" perhaps?

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

  • Comment on Re: Secret Perl Operators: the boolean list squash operator, x!!

Replies are listed 'Best First'.
Re^2: Secret Perl Operators: The Highlander List Asserter
by shmem (Chancellor) on Jul 31, 2006 at 19:23 UTC
    Since binary "x" works like stated in perlop
    Binary "x" is the repetition operator. In scalar context or if the left operand is not enclosed in parentheses, it returns a string consisting of the left operand repeated the number of times specified by the right operand. In list context, if the left operand is enclosed in parentheses or is a list formed by "qw/STRING/", it repeats the list. If the right operand is zero or negative, it returns an empty string or an empty list, depending on the context.
    this operator resolves basically to !!. I'd call that one:

    The Highlander Operator.

    It resolves any gazillion operations on the rhs to just 1 (One).

    ()x!! then is the list asserter. Of course, a list cannot be asserted better than through the Highlander Himself - so it's full name is "The Highlander List Asserter" :-)

    --shmem

    _($_=" "x(1<<5)."?\n".q/)Oo.  G\        /
                                  /\_/(q    /
    ----------------------------  \__(m.====.(_("always off the crowd"))."
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

      "Boolean Cast Operator" would be a less cryptic name than "Highlander Operator" for !!.

      It's not even correct to say it returns 1. For example, print "[", !!1, "]" prints []. For a true argument, !! returns the dualvar 1/''.

      Update: I got it backwards. True = dualvar (PVNV) 1/'1', False = dualvar (PVNV) 0/''.

        Hmm? Is that platform dependent?
        lt-gm [gm] 21:43 ~ > perl -le 'print "[", !!1, "]"' [1]

        Linux, perl 5.8.8. I choose "Higlander Operator" following the unstated naming conventions other secret operators follow ;-)

        --shmem

        _($_=" "x(1<<5)."?\n".q/)Oo.  G\        /
                                      /\_/(q    /
        ----------------------------  \__(m.====.(_("always off the crowd"))."
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re^2: Secret Perl Operators: the boolean list squash operator, x!!
by Aristotle (Chancellor) on Jul 31, 2006 at 16:57 UTC

    Hehe, thanks, but Im afraid I cant claim credit for this one. I wouldnt have gotten there without a nudge from TheLarry.

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://564796]
help
Chatterbox?
[Corion]: ... I'm not really knowledgeable about good guitar players
[stonecolddevin]: I've been on a Stevie Ray Vaughan kick lately: https://www. youtube.com/watch? v=wVjdMLAMbM0
[stonecolddevin]: Corion I haven't heard much of his work to be honest.
[erix]: here is a nice cover, stevieb
[planetscape]: hello, Corion
[Corion]: Hi planetscape!
[stevieb]: Corion I like the groundbreaking ones (guitar players). I have the ability to pick up on sounds that are groundbreaking or specific to a person, thanks to my years of doing recording/mixing/ sampling (hip-hop mind you, but years of it...
[stevieb]: ...has honed in my skills of recognizing sound
[stevieb]: All of the early members are coming out of the woodwork today :) Hey, planetscape
[Corion]: This cover version had so much promise but the singing is underwhelming :-/

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-06-22 21:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (531 votes). Check out past polls.