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.