without defined order but which permit duplication, i.e., more than one element. We define the function #(a B) to be the number of occurrences of the element a in the bag B. For example, #(1, [1 1 2 3 4 4 5]) is 2 and #(5, [1 1 2 3 4 4 5]) = 1. sum : List × List -> List This function should take as arguments two lists representing bags and should return the list representing the list resulting from simply appending the input lists together. Racket code only please.
Sets are collections (1) without defined order and (2) not allowing duplication. Multisets, also called “bags” are collections without defined order but which permit duplication, i.e., more than one element. We define the function #(a B) to be the number of occurrences of the element a in the bag B. For example, #(1, [1 1 2 3 4 4 5]) is 2 and #(5, [1 1 2 3 4 4 5]) = 1.
sum : List × List -> List
This function should take as arguments two lists representing bags and should return the list representing the list resulting from simply appending the input lists together.
Racket code only please. No loops
Allowed:
1. define, let
2. lambda
3. cons, car, cdr, list, list?, append, empty?, length, equal?
4. and, or, not
5. if, cond
7. +, -, /, *
Thank you!
Step by step
Solved in 2 steps