template <class Name, class Exp, class Body>
struct letrec
{
// unspecified
};
Recursive version of let
. It does the binding in Body
and in Exp
as well, thus Exp
can refer to itself recursively by Name
.
#include <mpllibs/metamonad/letrec.hpp>
For any n
, x
and f
classes, where none of them are the same and t
template:
letrec<n, x, f>
is equivalent to
let<n, syntax<eval_letrec<n, x, f>>, f>
using boost::mpl::times;
using boost::mpl::plus;
using boost::mpl::minus;
using boost::mpl::int_;
using boost::mpl::equal_to;
struct fact_;
typedef var<fact_> fact;
typedef
eval_syntax<
letrec<
fact,
syntax<
lambda_c<
n,
if_<
equal_to<n, int_<0>>,
int_<1>,
lazy<times<apply<fact, minus<n, int_<1>>>, n>>
>
>
>,
syntax<lazy<apply<fact, int_<3>>>>
>
>::type
fact_3;
Copyright Abel Sinkovics (abel at elte dot hu) 2011. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt