Skip to content

Instantly share code, notes, and snippets.

@leino
leino / glinv.hs
Created January 19, 2012 10:08
Slight extension of http://blog.sigfpe.com/2011/10/quick-and-dirty-reinversion-of-control.html, which adds input capabilities
{--
This file is a slight extension of Sigfpe's "Quick and dirty reinversion of control":
http://blog.sigfpe.com/2011/10/quick-and-dirty-reinversion-of-control.html
I only added input capabilities: yieldInput + modification to yield
and of course the lines in imperative (i.e. our re-captured "main loop") which have to do with getting input.
--}
#include <stdio.h>
int powers_recursive(int b, int l){
if(l>0){
for(int i=0; i<b-1; ++i){
int p = powers_recursive(b, l-1);
printf("%d", p);
}
powers_recursive(b,l-1);
return l;