[ prog / sol / mona ]

prog


Monads,Async/Await : Algebraic Effects in C99

38 2021-01-15 04:26

//using the new blankapply (from updated headers)
#include "Util/void.h"
#define prefix4(tup) (r-=first(detuple(tup)),r<0.0)?(second tup):
#define roll(tuples...) ({double r=rdouble();blankapply(prefix4,tuples)"";})

int main(){
#define OTHERWISE 1.0
puts(roll((0.5, "50% chance"),
(0.2, "20% chance"),
(OTHERWISE, "30% chance")));

;}

69


VIP:

do not edit these