- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
int main() {
interpretator_t i;
i.eval(
{let, "factorial_helper", {quote, {"this", "num"},
{if_, {eq_, {"num"}, 0}, 1, {mul_, {"num"}, {{"this"}, {"this"}, {sub_, {"num"}, 1}}}}
},
{let, "factorial", {quote, {"num"}, {{"factorial_helper"}, {"factorial_helper"}, {"num"}}},
{do_,
{write_, "vvedite chislo: "},
{assign_, "x", {to_number_, {read_}}},
{write_, "factorial: "},
{write_, {{"factorial"}, {"x"}}},
{write_, "\n"}
}
}}
);
return 0;
}
Смотрите, какой лисп я написал. Он еще и ленивый.