Actually, that was about what I started with. I wasn't really 'golfing', more like 'goofing' -- wanting something short (sure), but also unusual/idiomatic, and either really fast or really slow. It went something like this:     keys%{map{$_=>1}@list} "Way too conventional. Almost clear. And I don't like the 'map{}'."     keys%{map $_,0, @list} "Better, except it doesn't work. That comma is a problem. How to get rid of it... Oh!"     keys%{map$_=>0,@list} "Hrm, that's almost back were I started. D'oh! And it doesn't work, either. Ooh, I'll use 'x' instead!"     keys%{map$_ x2,@list} "Oops, I mean..."     keys%{map ($_)x2,@list} "Uhh... no. I hate that rule! I liked it better back when we didn't try to pretend that whitespace didn't sometimes have syntactic significance."     keys%{map+($_)x2,@list} "Not bad. But I don't like 'func+(' much. Heck, I don't like 1-to-many map, anyway (it still feels 'slow' to me and yet isn't slow enough). Maybe I'll go for maximum speed, maximum functionality (preserve order and references)..."     do{my%h;grep!$h{$_}++,@list} (Actually, I didn't get it nearly that tight before giving up) "Hrm, don't like that '@list' in the middle. Maybe..."     sub{my%h;grep!$h{$_}++,@_}->(@list) "Er, that didn't help. Okay, forget 'maximum functionality'!"     keys%{@list[...]} "But what to put for '...'? Too bad things like @list[0..-1] don't work..."     keys%{@x[0..$#x,1..$#x]} "Hrm... And doesn't work for odd sizes..."     keys%{@x,reverse@x} "'reverse' is such a long name for a function that can be so useful in golf. Oh, I'm not golfing. Yeah, that's not bad. It works for even and odds sizes but kinda 'for different reasons'. It might even be faster than a 1-to-many map version... maybe. Heck, let's see..."

...just type in a benchmark script directly into 'perl' since I have console line editing...

"Wow! It's 75% faster than even using the usually fastest @hash{@list}= () trick! Maybe it is worth posting."

...compose and preview post...

"Oh, if I'm going to publicly claim 'fastest', I should verify that the two solutions produce the same results... Huh? Why is that the empty list? Oh, '%{}' isn't enough, I need '%{{}}'!"

...rerun benchmark...

"D'oh! 50% slower... Ah, heck, it is still kinda goofy. I'll post it anyway."

And, oh, congratulations and ++sauoq! Nice golfing! (:

        - tye (but my friends call me "Tye")

In reply to (tye)Re: Unique strings by tye
in thread Unique strings by tye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.