Jensen's Device: Difference between revisions

Add Factor example
(Add Factor example)
Line 395:
</pre>
 
=={{header|Factor}}==
Similar to the Java and Kotlin examples:
<lang factor>: sum ( lo hi term -- x ) [ [a,b] ] dip map-sum ; inline
 
1 100 [ recip ] sum .</lang>
 
This version is a bit closer to the original, as it increments <code>i</code> in the caller's namespace.
<lang factor>SYMBOL: i
 
: sum ( i lo hi term -- x )
[ [a,b] ] dip pick [ inc ] curry compose map-sum nip ;
inline
 
i 1 100 [ recip ] sum .</lang>
{{out}}
<pre>
5+522561233577855727314756256041670736351/2788815009188499086581352357412492142272
</pre>
 
=={{header|Forth}}==
1,808

edits