/* 1999-2003, Rony G. Flatscher, Wirtschaftsuniversitaet Wien, Austria, Europe A *possible* solution to excercise: 9+10+11 (2) */ Fruit_Bag = .bag~of( "Apfel", "Apfel", "Birne", "Erdbeere", "Apfel", "Banane", , "Zwetschke", "Zwetschke", "Banane", "Apfel", "Birne", "Papaya", , "Erdnuss", "Erdnuss", "Erdnuss", "Erdnuss", "Erdnuss", "Apfel", , "Erdnuss", "Ananas", "Banane", "Zwetschke", "Birne", "Birne", , "Zwetschke", "Zwetschke", "Banane", "Apfel", "Birne", "Papaya", , "Erdnuss", "Erdnuss", "Erdnuss", "Apfel", "Erdnuss", "Ananas", , "Banane", "Erdnuss", "Erdnuss", "Erdnuss", "Erdnuss", "Erdnuss", , "Apfel", "Erdnuss", "Ananas", "Banane", "Erdnuss", "Papaya", , "Mango", "Erdnuss", "Erdnuss", "Apfel", "Erdnuss", "Ananas", , "Banane", "Birne" ) Ordered_List = .list~of("Apfel", "Banane", "Birne", "Zwetschke") Fruit_Set = .set~new~union(Fruit_Bag) Ordered_Fruit_Set = Fruit_Set~intersection(Ordered_List) Other_Fruit_Set = Fruit_Set~difference(Ordered_List) CALL dump Fruit_Bag, Ordered_Fruit_Set, "Received Fruits (ordered)", .false CALL dump Fruit_Bag, Other_Fruit_Set, "Received Fruits (not ordered)", .false CALL dump Fruit_Bag, Ordered_List, "Received Fruits (ordered)", .true CALL dump Fruit_Bag, Other_Fruit_Set, "Received Fruits (not ordered)", .true ::ROUTINE dump USE ARG bag, collection, title, bWithCount bWithCount = (bWithCount="1") SAY title tmpString = "" DO fruit OVER collection IF \(bag~hasindex(fruit)) THEN ITERATE IF bWithCount THEN tmpString = ":" RIGHT(bag~allat(fruit)~items, 3) SAY RIGHT(fruit, 21) || tmpString END SAY RETURN