Help me with my inability to see a simple solution

Alex Tweedly alex at tweedly.net
Thu Dec 16 19:48:07 EST 2010


Depends on whether the data is known to be already in order. If not, 
then you need to uncomment the sort command.

btw. sorry, this doesn't use arrays, but it will be much faster than the 
array method(s) if the data set is large.
>
> function other pMin, pMax, pList
>     put empty into tMissingList
>     put empty into tDuplicateList
>
>     -- sort the data if needed
>     -- sort items of pList ascending numeric
>
>     put pMin-1 into tLast
>     repeat for each item N in pList
>         if N = tLast+1 then
>             put N into tLast
>             next repeat
>         end if
>         if N = tLast then
>             put N & comma after tDuplicateList
>             next repeat
>         end if
>         repeat with i = tLast+1 to N-1
>             put i & comma after tMissingList
>         end repeat
>         put N into tLast
>     end repeat
>     return (char 1 to -2 of tMIssingList) &cr& \
>             (char 1 to -2 of tDuplicateList)
> end other
-- Alex.


On 16/12/2010 23:29, william humphrey 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?
>
> 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
>





More information about the Use-livecode mailing list