def split_walk.go
unified-nsga-iii@0.2.2.0 · non_dominated_sort.bend:209
import unified-nsga-iii@0.2.2.0/non_dominated_sort.bend as NonDominatedSort
import Base
import unified-nsga-iii@0.2.2.0/util.bend as Util
209
210
211def split_walk.go(+all: List<&2, Row>, +fuel: Nat, cand: List<&2, Row>) -> Split:
212 match fuel cand:
213 case 0n Nil{}:
214 Split{Nil{}, Nil{}}
215 case 0n +r <> rest:
216 split_put(r, split_walk.go(all, 0n, rest), row_dom(all, r))
217 case 1n+p Nil{}:
218 Split{Nil{}, Nil{}}
219 case 1n+p +r <> Nil{}:
220 split_put(r, Split{Nil{}, Nil{}}, row_dom(all, r))
221 case 1n+p h <> t:
222 +xs = {h <> t : List<&2, Row>}
223 +mid = Nat.div(Util.list_len(Row, xs), 2n)
224 lo hi = split_walk.go(all, p, List.take(&2, Row, xs, mid)) split_walk.go(all, p, List.drop(&2, Row, xs, mid))
225 split_cat(lo, hi)