def rangize(break_points,length):
bps = array_map(break_points,uniform_index,length)<EOL>bps.sort()<EOL>bps = prepend(bps,<NUM_LIT:0>)<EOL>bps = append(bps,length)<EOL>bps = uniqualize(bps)<EOL>bpslen = bps.__len__()<EOL>secs=[(<NUM_LIT:0>,bps[<NUM_LIT:0>])]<EOL>for i in range(<NUM_LIT:0>,bpslen-<NUM_LIT:1>):<EOL><INDENT>r = (bps[i],bps[i+<NUM_LIT:1>])<EOL>secs.append(r)<EOL><DEDENT>secs.append((bps[bpslen-<NUM_LIT:1>],length))<EOL>if(secs[<NUM_LIT:0>][<NUM_LIT:0>] == secs[<NUM_LIT:0>][<NUM_LIT:1>]):<EOL><INDENT>secs.pop(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>if(secs[-<NUM_LIT:1>][<NUM_LIT:0>] == secs[-<NUM_LIT:1>][<NUM_LIT:1>]):<EOL><INDENT>secs.pop(-<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>return(secs)<EOL>
break_points = [1,3,9,12,-2]
length = 15
secs = rangize(break_points,length)
forEach(secs,print)