[ prog / sol / mona ]

prog


Monads,Async/Await : Algebraic Effects in C99

42 2021-01-15 06:57

//argv vector version, in macro form
#include "Util/void.h"
#define rollarg(argv) ({double r=rdouble();char* res="";\
for(size_t i=1; argv[i]/*stop on nullarg*/;i++){r-=atof(argv[i]);\
if(r<0.0){res=tmax(strrchr(argv[i],',')+1,argv[i])/*protect from invalid arg format*/;break;}};\
res;})

int main(int argc,char**argv){
puts(rollarg(argv));
// ./chal 0.5,"50% chance" 0.2,"20% chance" 1.0,"30% chance"

;}

69


VIP:

do not edit these