<div dir="ltr">Frequently throughout a program I am working on, I would like to specify a probabalistic choice between two (for the sake of simplicity) procedures that might be applied at runtime. <div><br></div><div>at present, I have defined a function like so :</div>

<div><br></div>    (: odds-on ((Any * -> Any) (Any * -> Any) Real -> (Any * -> Any)))<br>    (define (odds-on choice alternative odds)<br>      (cond [(< (random) odds) choice]<br>            [else alternative]))<div>

<br></div><div>s.t. I could do something like this > ((odds-on common-thing rare-thing .80) 'an-argument "an argument of different type")</div><div>and around 80% of the time it would apply common-thing to the arguments, and around 20% of the time it would apply rare-thing. </div>

<div><br></div><div>I understand that my type annotation above is wrong for what I want to do--I want to be able to use odds-on with arbitrary function types and function arity, while the above is the form for homogenous rest args. I can also see how this might be an insoluble type conundrum from the type-checker's point of view (but my understanding of type systems is weak, so I'm guessing). </div>

<div><br></div><div>I've read over the docs for parameterized types and heterogenous variable arity rest arguments at least a dozen times, so I'm here looking for advice! My understanding of the purpose of macros in Racket leads me to believe that might be worth exploring, but I'm also wary of opening up a whole other can of worms at this point. </div>

<div><br></div><div>Is it possible to do what I have asked with type checking? Would I better off abandoning type checking and keeping the syntax? Is there some far Rackety-er way of achieving this effect? </div><div><br>

</div><div>Thanks for the help, again!</div></div>