6 lines
309 B
Text
6 lines
309 B
Text
fcn addItem(pairs,it){ // pairs is list of (cost of:,names), it is (name,w,v)
|
|
w,left,right:=it[1],pairs[0,w],pairs[w,*];
|
|
left.extend(right.zipWith(
|
|
fcn([(t1,_)]a,[(t2,_)]b){ t1>t2 and a or b },
|
|
pairs.apply('wrap([(tot,names)]){ T(tot + it[2], names + it[0]) })))
|
|
}//--> new list of pairs
|