Jump to content

Jensen's Device: Difference between revisions

→‎{{header|Forth}}: replaced FVARIABLE ii with VARIABLE i1 (i is integer in the task description)
m (→‎{{header|Wren}}: Changed to Wren S/H)
(→‎{{header|Forth}}: replaced FVARIABLE ii with VARIABLE i1 (i is integer in the task description))
Line 733:
The following version passes i and 1/i as execution tokens and is thus closer to the original, but less idiomatic:
 
<syntaxhighlight lang="forth">fvariable: iisum \( i-xt islo ahi Forthterm-xt word-- thatr we need)
\ stack effects: sumi-xt ( xt1-- loaddr hi); xt2term-xt ( -- rr1 )
0e swap 1+ rot ?do ( addrr1 xtxt1 r1xt2 )
i s>f2 overpick execute f! dup execute f+
loop 2drop ;
 
' ii 1 100 :noname 1e ii f@ f/ ; sum f.</syntaxhighlight>
variable i1 \ avoid conflict with Forth word I
' iii1 1 100 :noname 1e iii1 f@ s>f f/ ; sum f.</syntaxhighlight>
 
=={{header|Fortran}}==
5

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.