unparsable piece of python code for a java developer -
i comming java world , have hard time understand following piece of code.
sortix=['a2', 'a4', 'a1', 'a3', 'a5'] citems=[sortix] print citems while len(citems)>0: citems=[i[j:k] in citems j,k in ((0,len(i)/2), (len(i)/2,len(i))) if len(i)>1] print citems
what line citems=[i[j:k] in citems j,k in ((0,len(i)/2), (len(i)/2,len(i))) if len(i)>1]
? how write in java (or scala or groovy)?
edit
thx reblochon masque able understand this! if 1 interested, translated groovy statement this:
citems = citems.findall { -> it.size() > 1} .collectmany { -> [it.sublist(0, it.size().intdiv(2)), it.sublist(it.size().intdiv(2), it.size())] }
what line do?
citems = [i[j:k] in citems j, k in ((0, len(i) / 2), (len(i) / 2, len(i))) if len(i) > 1]
it partitions each inner lists contained citems
2 sublists of half size (containing each half of elements), except when sublist contains 1 element, ignored.
Comments
Post a Comment