metacard digest, Vol 1 #552 - 2 msgs

John Vokey vokey at uleth.ca
Tue Mar 18 12:59:01 EST 2003


On Tuesday, March 18, 2003, at 10:03  AM, WA wrote:

> Hi again,
>
> If Mr J. Vokey is right about the permutations Mr E. Engle really wants
> then things could have looked like this:
>
> on mousUp
>    put perm(fld "in") into fld "out"
> end mouseUp
>
> function perm factors
>    put the length of factors into x
>    put char 2 to -1 of (10 ^ x) into a
>    repeat with i = 1 to 2 ^ x - 1
>      put baseConvert(i, 10, 2) into b
>      put char 1 to x - the num of chars in b of a & b into b
>      repeat with j = 1 to x
>        if char j of b = 1 then put char j of factors after thecollector
>      end repeat
>      put thecollector & cr after theresult
>      put "" into thecollector
>    end repeat
>    sort theresult
>    sort lines of theresult by number of chars in each
>    return theresult
> end perm
>
>
> Have a nice night,
> WA
>
I like it: nice use of the decimal to binary conversion to implement my 
algorithm (i.e., 1/0 flags to indicate presence/absence of a given 
letter). Unfortunately, as with my version, it is not recursive, as was 
originally asked for.  Furthermore, it requires the baseConvert 
function, not available in most other XTalks, including hypertalk, and 
it was in the hypercard list that I first saw the request.

-- 
John R. Vokey, Ph.D.                       |\      _,,,---,,_
Professor                                  /,`.-'`'    -.  ;-;;,_
Department of Psychology and Neuroscience  |,4-  ) )-,_. ,\ (  `'-'
University of Lethbridge                  '---''(_/--'  `-'\_)




More information about the metacard mailing list