Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Puzzlement in Splitsville

by BrowserUk (Patriarch)
on Jun 20, 2005 at 09:47 UTC ( [id://468265]=note: print w/replies, xml ) Need Help??


in reply to Puzzlement in Splitsville

In response to BrowserUk's question, yes order matters.

I guess you could do the FP thing:

sub oddEls; sub oddEls{ @_ ? (( shift, shift )[ 0 ], oddEls @_) : () } print oddEls 'aaabbcddddaee' =~ /((.)\2*)/g;; aaa bb c dddd a ee

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Replies are listed 'Best First'.
Re^2: Puzzlement in Splitsville
by Anonymous Monk on Jun 20, 2005 at 10:56 UTC
    Your solution works only because oddEls always gets an even length list. Replace @_ ? with @_ > 1 ?, and oddEls also works with odd length lists.

      Are you sure?

      print oddEls 1 .. 9;; 1 3 5 7 9 print oddEls 1 .. 10;; 1 3 5 7 9

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (9)
As of 2024-03-28 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found