#include <iostream>

#include "learn.hpp"

#define eol '\n'

struct funkloop
{
  int i;
  funkloop(int n)
  {
    i=n;
  }
  template <class T>
  void operator () (T fun)
  {
    if (i>0)
    {
      funkloop next (i-1);
      next (fun);
      fun();
    }
  }
};

template <class T>
struct conditional
{
  T call;
  conditional (T fun)
  {
    call = fun;
  }
  void operator () (int so)
  {
    if (so)
    {
      call();
    }
  }
};

int main()
{
  funinc f (1);
  std::cout << f(0) << f(f(0)) << f(f(f(0))) << eol;
  funfib fib (7);
  std::cout << fib(1,1) << eol;
  fundec ff ;
  std::cout << ff(ff(3)) << eol;

  //funkloop cinqfois (5);
  //cinqfois(funhello ());
  
  funhello helllo;
  conditional <funhello> hello (helllo);
  hello(1);
  
  return 0;
}
