items:=T( // item: (name,weight,value,#) T("apple", 39, 40,3),T("banana", 27,60,3), T("beer", 52, 10,3),T("book", 30,10,2),T("camera", 32, 30,1), T("cheese", 23, 30,1),T("compass", 13,35,1),T("glucose", 15, 60,2), T("map", 9,150,1),T("note-case",22,80,1),T("sandwich", 50, 60,2), T("socks", 4, 50,1),T("sunglasses",7,20,1),T("suntan cream",11, 70,1), T("t-shirt", 24, 15,2),T("tin", 68,45,3),T("towel", 18, 12,2), T("trousers", 48, 10,2),T("umbrella", 73,40,1),T("water", 153,200,2), T("overclothes",43, 75,1),T("waterproof trousers",42,70,1) ); weight:='wrap(knapsack){ // knapsack is (cost, (nm,#,nm,#...)) knapsack[1].pump(List,Void.Read, // read nm,#, first read is implicit 'wrap(nm,n){ items[items.filter1n(fcn(it,nm){ it[0]==nm },nm)][1]*n }) .sum(0) };