Generating Specials
Take a look at how to generate the list of specials, regular items and items on the specials.
Generating the list of specials
We’ll start with the list of specials since it’s conceptually simpler and a prerequisite of other generators. The method here is to first extract the list of all item names from the price list, and then create a matching table of specials. Let’s take a look at how it can be done.
special_list(PriceList) ->
Items = [Name || {Name, _} <- PriceList],
?LET(Specials, list({elements(Items), choose(2,5), integer()}),
lists:ukeysort(1, Specials)). % no dupes
The generated list of specials contains the name of the item, how many of them are required for the special to apply, and then the price for the whole group. The specials are generated from randomly selected entries ...