[ prog / sol / mona ]

prog


Monads,Async/Await : Algebraic Effects in C99

44 2021-01-15 07:14

//its also possible to use percentages directly
#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])*0.01;\
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){
printf("%s%% chance",rollarg(argv) );
// ./roll 50.1 20.0 29.9
// 50.1% chance

;}

69


VIP:

do not edit these