Sum of a series: Difference between revisions
→{{header|TXR}}: Variant C.
(→{{header|TXR}}: Added.) |
(→{{header|TXR}}: Variant C.) |
||
Line 1,566:
Reduce with + operator over a lazily generated list.
Variant
<lang
sum="1.64393456668156"</lang>
Variant
<lang
sum="1.64393456668156"</lang>
Variant B: generate lazy integer range, and pump it through a series of function with the help of the <code>chain</code> functional combinator and the <code>op</code> partial evaluation/binding operator.
<lang txr>txr -c '@(bind sum @[[chain range (op mapcar (op / 1.0 (* @1 @1))) (op reduce-left + @1 0)] 1 1000])'
sum="1.64393456668156"</lang>
=={{header|UnixPipes}}==
|