Compile-time calculation: Difference between revisions

Added C3 code.
m (→‎{{header|TXR}}: Fix markdown style code markup to code element.)
(Added C3 code.)
Line 442:
leave
ret</syntaxhighlight>
 
 
=={{header|C3}}==
C3 has semantic macros that use a different syntax from the regular runtime syntax.
 
<syntaxhighlight lang="c">macro int factorial($n)
{
$if ($n == 0):
return 1;
$else:
return $n * factorial($n - 1);
$endif;
}
 
extern fn void printf(char *fmt, ...);
 
fn void main()
{
int x = factorial(10);
printf("10! = %d\n", x);
}</syntaxhighlight>
 
{{out}}
<pre>10! = 3628800</pre>
 
=={{header|Clojure}}==
38

edits