Mapping into two lists

Marcus Stojek stojek at part-gmbh.de
Mon Sep 3 11:59:06 CEST 2001


Hi,

I have a sorted list of int.  To generate an input file for
a special software I have to split this list into two. Instead of
explaining I'll give an example:

List: [ 1, 3,4,5,6,7, 9, 11,12,13,14,15, 17]

# start and end value of continuous list segment:
Output list1: [3,7, 11,15] 
# single values:
Output list2: [1,9,17] 


input file:
GROUP
generate,3,7 #generates values from 3 to 7 step 1
generate,11,15
add 1,9,17
END GROUP


I do have a piece of code with a lot of ifs and whiles and
len(list)-1 and stuff. I bet this can be done much easier with some
sophisticated mapping.

Thanks
Marcus






More information about the Python-list mailing list