Help me with my inability to see a simple solution
Terry Judd
tsj at unimelb.edu.au
Thu Dec 16 19:03:55 EST 2010
On 17/12/10 10:29 AM, "william humphrey" <bill at bluewatermaritime.com> wrote:
> My math skills are terrible but this is something I can do in excel but
> which should also be easy to do with a nested array in livecode. I want to
> build a function that returns the numbers that are out of sequence in a list
> of numbers. Say you are given (3,4,5,6,6,7,8,9,10,12,13,13,14) and the
> function should return:
>
> (1,2,11 - missing)
> (6,13 - duplicate)
>
> Can someone please help me write this function?
How 'bout this...
pMin is your minimum value
pMax is your maximum value
pList is your list of numbers to test
The output is a list of missing numbers (line 1) and repeat numbers (line 2)
function stuff pMin, pMax, pList
put empty into tMissingList
put empty into tDuplicateList
repeat with i = pMin to pMax
put true into tMissing
put empty into tDuplicate
repeat for each item tValue in pList
if tValue = i then
put false into tMissing
put i & comma after tDuplicate
end if
end repeat
if tMissing then
put i & comma after tMissingList
end if
if the number of items in tDuplicate > 1 then
put i & comma after tDuplicateList
end if
end repeat
return (char 1 to -2 of tMIssingList) &cr& \
(char 1 to -2 of tDuplicateList)
end stuff
Terry...
>
> Thanks in advance.
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
--
Dr Terry Judd | Senior Lecturer in Medical Education
Medical Education Unit
Melbourne Medical School
The University of Melbourne
More information about the use-livecode
mailing list