C function in metaTalk?
Dr. John R. Vokey
vokey at uleth.ca
Sat Mar 15 23:11:01 EST 2003
On Saturday, March 15, 2003, at 10:03 AM, on
metacard-request at lists.runrev.com, Wouter Abraham wrote:
>
> Hi Eric,
>
> Something like this? :
>
>
> local theResult
> on mouseUp
> put "" into theResult
> put abra(fld "orig") into fld "result"
> end mouseUp
>
> function abra x
> if x <> "" then
> put char 2 to -1 of x into y
> repeat until x = ""
> put cr & x before theCollector
> delete char -1 of x
> end repeat
> put theCollector after theResult
> get abra(y)
> else return char 2 to -1 of theResult
> end abra
>
> Have a nice evening,
> WA
>
Unfortunately, this function does not return all the different sets of
the letters as input. If the input is "abc", for example, it returns:
a
ab
abc
b
bc
c
but misses "bc". The missed sets are even more obvious with "abcd" as
input:
a
ab
abc
abcd
b
bc
bcd
c
cd
d
In general, there are 2^k-1 possible sets, where k=the number of
letters. For 4 letters, there should be 15 sets, not the 10 shown here.
--
John R. Vokey, Ph.D. |\ _,,,---,,_
Professor /,`.-'`' -. ;-;;,_
Department of Psychology and Neuroscience |,4- ) )-,_. ,\ ( `'-'
University of Lethbridge '---''(_/--' `-'\_)
More information about the metacard
mailing list