Weekend challenge

Geoff Canyon gcanyon at gmail.com
Sun Jun 30 21:33:08 EDT 2013


This is just one piece, but here's a function that takes a list much like
yours and a list of columns, and returns the instances where a column
repeats itself out of order. So this (note the true being passed to ignore
empty values):

   replace tab with comma in yourData
   put isSequential(yourData,"1,2,3",true)

will return something like:

25,2,3
26,2
37,1
140,3
155,1
156,1
163,2

Which means that in line 25, items 2 and 3 were out-of-sequence repeats,
etc.

function isSequential theList,columnsToCheck,ignoreEmpties
   put 0 into lineNumber
   repeat for each line L in theList
      add 1 to lineNumber
      put lineNumber into lineErrorReport
      repeat for each item i in columnsToCheck
         put item i of L into thisItem
         if ignoreEmpties and thisItem is empty then next repeat
         if thisItem is lastItem[i] then next repeat
         put thisItem into lastItem[i]
         if itemsSeen[i][thisItem] is not empty then put comma & i after
lineErrorReport
         put 1 into itemsSeen[i][thisItem]
      end repeat
      if lineErrorReport is not lineNumber then put lineErrorReport & cr
after R
   end repeat
   return R
end isSequential



More information about the use-livecode mailing list