[ prog / sol / mona ]

prog


Monads,Async/Await : Algebraic Effects in C99

40 2021-01-15 04:37

//its also possible to remove the #define OTHERWISE
#include "Util/void.h"
#define prefix4(tup) ((r-=(first tup))<0.0)? tup:
#define roll(tuples...) ({double r=rdouble();blankapply(prefix4,remlast(tuples)) last(tuples);})
int main(){
puts(roll((0.5, "50% chance"),
(0.2, "20% chance"),
(OTHERWISE, "30% chance")));

;}

69


VIP:

do not edit these