I want to make an even more complex random function in Racket.
The function will have two input list as parameters (assuming the lists will have the same length):
-
One will be for the elements it can return
-
The other will be for the probability. Let my make it clear, if the list is ‘(1 1 2) the probability to get the first element will be the same than the second element, but the 3rd element’s probability will be double than the first and the second. If the list is ‘(1 2 4) the probability of the second element will be the double of the first element but the half of the 3rd element.
So if we have as the inputs arguments ‘(e t k) and ‘(1 2 3). The probability of getting a “t” will be the double of an “e”. And the probability of getting a “k” will be the triple of an “e”.
If we have as the inputs arguments ‘(k u y t) and ‘(1 1 2 1). The probability of getting a “y” will be the double of a “k”, “u” and “t”. And the probability of getting a “k”, “u” and “t” will be the same between them.
Thanks!!
Aucun commentaire:
Enregistrer un commentaire