/* (c) 1999-2005, Rony G. Flatscher, Wirtschaftsuniversitaet Wien, Austria Europe A *possible* solution to excercise # 16 */ Fruit_Bag = .bag~of( "apple", "apple", "pear", "strawberry", "apple", "banana", - "plum", "plum", "banana", "apple", "pear", "melon", - "peanut", "peanut", "peanut", "peanut", "peanut", "apple", - "peanut", "pineapple", "banana", "plum", "pear", "pear", - "plum", "plum", "banana", "apple", "pear", "melon", - "peanut", "peanut", "peanut", "apple", "peanut", "pineapple", - "banana", "peanut", "peanut", "peanut", "peanut", "peanut", - "apple", "peanut", "pineapple", "banana", "peanut", "melon", - "mango", "peanut", "peanut", "apple", "peanut", "pineapple", - "banana", "pear" ) Ordered_List = .list~of("apple", "banana", "pear", "plum") 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