On Thu, 2004-06-10 at 09:26, Steve Wampler wrote:

> Now, performance wasn't a requirement (nor was brevity or clarity
> or any other measure, for that matter!) but it's interesting to look at.

Steve Hunter has pointed out a solution found in an old issue
of the Icon Newsletter (Issue 18, from 1985!):

procedure main()
    while write(anagram(read()))
end
  
procedure anagram(s)
    local c, s1

    s1 := ""               # start with the empty string
    every c := !cset(s) do # for every character in s
        every find(c,s) do     # and every time it occurs in s
            s1 ||:= c              # append one
    return s1
end

And here are it's times:

Case 1:
weaver% RunTests
------------------ icon18 -----------------------
        1.48s user 0.23s system 100% cpu 1.705 total

Case 2:
weaver% RunTests --infile=input2.txt --valid=valid3.txt
------------------ icon18 -----------------------
       3.60s user 0.07s system 99% cpu 3.687 total

Clear and fast - nine years ago!

-- 
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