

#print args

"""
scan_pos.set([])
scan_val.set([])
def after(rec):
   scan_val.append(rec.values[0])
   scan_pos.append(rec.positions[0])
"""

#TODO: this is workaround to CAS not supporting dynamic arrays
def after(rec):
   global arrpos,arrval
   print rec.index
   arrval =  scan_val.take().tolist()
   arrpos =  scan_pos.take().tolist()
   arrval[rec.index] = rec.values[0]
   arrpos[rec.index] = rec.positions[0]
   arrval[rec.index:] = [rec.values[0]] * (len(arrval) -rec.index)
   arrpos[rec.index:] = [rec.positions[0]] * (len(arrpos) -rec.index)  
   scan_val.set(arrval)
   scan_pos.set(arrpos)

    
res = lscan(inp, (sin,out), scan_start.read(), scan_stop.read(), scan_step.read(), 0.1, after_read = after)

set_return(res.print())