On Thu, 2004-06-10 at 11:51, Steve Graham wrote:
> Steve,
> 
>    I'd be interested in what the Snobol solutions looked like (and probably an 
> explanation if available).

I only kept two - the first posted and then a fast one.

Here's the first posted SNOBOL4 solution (slightly modified
to produce output I can compare to a known valid solution):

           &ANCHOR = 0
           &FULLSCAN = 1
START    S = INPUT                                                 
:f(END)
SORTLP1 S LEN(1) $ C1 LEN(1) $ C2 *LLT(C2,C1) = C2 C1  :s(SORTLP1)
          OUTPUT = S                                                
:(START)
END

and the fast one (I modified it slightly so it would
work with multiple input lines - the original took
an embedded string):

              NextChar  = (TAB(*P) LEN(1) $ c TAB(*Q)) $ x
              FindChar  = BREAK(*c) $ y SPAN(*c) $ c
              UpdateP   = *?(P = P + 1) FAIL
              UpdateQ   = *?(Q = Q + SIZE(c))
              FunnySort = NextChar (FindChar | UpdateP) UpdateQ
LOOP         S = INPUT                      :F(END)
              Temp = &ALPHABET S
              P = 0
              Q = 256
FunnySort  Temp FunnySort = x c y     :S(FunnySort)
              Temp TAB(256) REM $ S
              OUTPUT = S                     :(LOOP)
END

I'm not about to try and explain these - it's been almost 30
years since I used S4 in anger and I'm sure my explanation would
be a disaster... any takers?  (I will say that I found the S4
solutions much harder to understand than the Icon ones, though
I'm willing to bet that the S4 users would feel exactly
the opposite... that's why we have so many programming
languages out there!)  I will happily explain my favorite
(of mine) Icon solution if anyone wants...

I *think* there's a bug in the second program not picking up the
last character in each input line correctly, but I'm probably
wrong or it is an artifact of my changes.

Here are the times, same machine and data as the Icon times,
using Phil Budne's csnobol4 implementation:

First program:
Case 1:
         1404.49s user 1.07s system 99% cpu 23:37.41 total

Case 2: Sorry - didn't even *try* to run this!


Second program (much more reasonable times!):
Case 1:
         38.46s user 0.13s system 99% cpu 38.718 total
Case 2:
         22.70s user 0.06s system 99% cpu 22.831 total

-- 
Steve Wampler -- [EMAIL PROTECTED]
The gods that smiled on your birth are now laughing out loud.


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to