Genii Weblog


Civility in critiquing the ideas of others is no vice. Rudeness in defending your own ideas is no virtue.


Thu 6 Jan 2005, 04:26 PM
For those who don't know Andrew Pollack, he is an awesome geek.  No, not some pocket protector wearing dweeb sort of geek (no offense meant to any pocket protecting dweebs who read my blog), but the sort who can take apart a broken laptop while sitting at a meeting, have it in pieces all over the table, fix the problem and put it back together and make it work, all without interrupting his train of thought.  His sessions at Lotusphere and elsewhere absolutely rock, and you should attend each and every one, including the repeats.  All that, and he's a fireman too.

Anyway, Rocky started this really, really, really long thread about what surprises people about you, which is well worth reading in its own right, and got sidetracked into a discussion of how to use formula language to reverse the old advertising ditty
twoallbeefpattiesspecialsaucelettucecheesepicklesonionsonasesameseedbun
to be
bunseedsesamieaononionspicklescheeselettucesaucespecialpattiesbeefalltwo
and not
nubdeesemasesanosnoinoselkcipeseehcecuttelecuaslaicepsseittapfeebllaowt
which doesn't sound too good to customers.  Andrew's answer was clean and elegant, as his code usually is (and I quote):
Yawn.

a := @Explode"two all beef patties special sauce lettuce cheese pickles onions on a sesame seed bun"" ");
@For( X := 0 ; X < @Elements(a) ; X := X + 1 ; T := T + " "@Subset(@Subset(a; @Elements(a) - X); -1));
@Prompt([Ok];"";T)


And I'm not kidding about the "Yawn".  Andrew likes to be a bit obnoxious.

Anyway, I was reading this, and realizes that I knew a geekier way, due to the special characteristics of this particular saying.  I tried it, and it works, and I posted it, but since it is comment #69, I'm not sure anybody will be able to appreciate the amazingness of my outgeeking Andrew.

So, here it is.
a:=@Explode"two all beef patties special sauce lettuce cheese pickles onions on a sesame seed bun"" ");
T:=@Implode(@Sort(a; [CustomSort];
                                          @Member($a;a)<@Member($b;a)); "");
@Prompt([Ok]; ""; T) 


Now, would you have ever thought of using @Sort?  Granted, I don't know whether my formula is faster than Andrews, or even much shorter than Andrew's, and I know full well mine is less useful than Andrew's since it depends on an odd characteristic of the specific sequence, but in the geekiness world, an @Sort with [CustomSort] parameter beats out an @For and in-line assignments with or without the @Member kicker.

Just thought I should share.

Copyright © 2005 Genii Software Ltd.