sclass CutListToBudget { settable double maxPrice; settable Iterable inputList; gettable L outputList; gettable double finalPrice; swappable double getPrice(A element) { throw unimplemented(); } *(IF1 *getPrice, double *maxPrice, Iterable *inputList) {} run { outputList = new L; finalPrice = 0; fOr (element : inputList) { double price = getPrice(element); if (finalPrice + price > maxPrice) break; finalPrice += price; outputList.add(element); } } L get() { if (outputList == null) run(); ret outputList; } int sum = 0; new L out; fOr (ssi : l) { if (sum >= maxLines) break; int linesToCopy = min(ssi.height(), maxLines-sum); if (linesToCopy < ssi.height()) break; out.add(ssi); //out.add(linesToCopy == ssi.height() ? ssi : ssi.topPart(linesToCopy)); sum += ssi.height(); } ret out; }