def intersection(l1, l2):
if len(l1) == <NUM_LIT:0> or len(l2) == <NUM_LIT:0>:<EOL><INDENT>return []<EOL><DEDENT>out = []<EOL>l2_pos = <NUM_LIT:0><EOL>for l in l1:<EOL><INDENT>while l2_pos < len(l2) and l2[l2_pos].end < l.start:<EOL><INDENT>l2_pos += <NUM_LIT:1><EOL><DEDENT>if l2_pos == len(l2):<EOL><INDENT>break<EOL><DEDENT>while l2_pos < len(l2) and l.intersects(l2[l2_pos]):<EOL><INDENT>out.append(l.intersection(l2[l2_pos]))<EOL>l2_pos += <NUM_LIT:1><EOL><DEDENT>l2_pos = max(<NUM_LIT:0>, l2_pos - <NUM_LIT:1>)<EOL><DEDENT>return out<EOL>
Returns intersection of two lists.  Assumes the lists are sorted by start positions