Compile-time calculation: Difference between revisions

Content added Content deleted
Line 499: Line 499:
You can also calculate all factorials for 1 to 20 before defining fact method :
You can also calculate all factorials for 1 to 20 before defining fact method :
<lang Oforth>20 seq map(#[ seq reduce(#*) ]) Constant new: ALLFACTS
<lang Oforth>20 seq map(#[ seq reduce(#*) ]) Constant new: ALLFACTS
func: fact(n) { ALLFACTS at(n) }</lang>
func: fact(n) { n ifZero: [ 1 ] else: [ ALLFACTS at(n) ] }</lang>


=={{header|OxygenBasic}}==
=={{header|OxygenBasic}}==