Compile-time calculation: Difference between revisions

Content added Content deleted
m (→‎{{header|Sidef}}: modified code to work with Sidef 2.10)
Line 795: Line 795:
=={{header|Sidef}}==
=={{header|Sidef}}==
The compile-time evaluation is limited at a constant expression, which cannot refer at any other user-defined data, such as variables or functions.
The compile-time evaluation is limited at a constant expression, which cannot refer at any other user-defined data, such as variables or functions.
<lang ruby>define n (10!);
<lang ruby>define n = (10!);
say n;</lang>
say n;</lang>


or:
or:
<lang ruby>define n (func(n){ n > 0 ? __FUNC__(n-1)*n : 1 }(10));
<lang ruby>define n = (func(n){ n > 0 ? __FUNC__(n-1)*n : 1 }(10));
say n;</lang>
say n;</lang>