Feigenbaum constant calculation: Difference between revisions
Content added Content deleted
No edit summary |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 12: | Line 12: | ||
{{trans|Python}} |
{{trans|Python}} |
||
< |
<syntaxhighlight lang="11l">V max_it = 13 |
||
V max_it_j = 10 |
V max_it_j = 10 |
||
V a1 = 1.0 |
V a1 = 1.0 |
||
Line 33: | Line 33: | ||
d1 = d |
d1 = d |
||
a2 = a1 |
a2 = a1 |
||
a1 = a</ |
a1 = a</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 54: | Line 54: | ||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
{{Trans|Ring}} |
{{Trans|Ring}} |
||
<syntaxhighlight lang="ada"> |
|||
<lang Ada> |
|||
with Ada.Text_IO; use Ada.Text_IO; |
with Ada.Text_IO; use Ada.Text_IO; |
||
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; |
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; |
||
Line 101: | Line 101: | ||
feigenbaum; |
feigenbaum; |
||
end Main; |
end Main; |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 122: | Line 122: | ||
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}} |
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}} |
||
{{Trans|Ring}} |
{{Trans|Ring}} |
||
< |
<syntaxhighlight lang="algol68"># Calculate the Feigenbaum constant # |
||
print( ( "Feigenbaum constant calculation:", newline ) ); |
print( ( "Feigenbaum constant calculation:", newline ) ); |
||
Line 151: | Line 151: | ||
a2 := a1; |
a2 := a1; |
||
a1 := a |
a1 := a |
||
OD</ |
OD</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 171: | Line 171: | ||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
<syntaxhighlight lang="awk"> |
|||
<lang AWK> |
|||
# syntax: GAWK -f FEIGENBAUM_CONSTANT_CALCULATION.AWK |
# syntax: GAWK -f FEIGENBAUM_CONSTANT_CALCULATION.AWK |
||
BEGIN { |
BEGIN { |
||
Line 198: | Line 198: | ||
exit(0) |
exit(0) |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 218: | Line 218: | ||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
==={{header|BASIC256}}=== |
==={{header|BASIC256}}=== |
||
< |
<syntaxhighlight lang="freebasic">maxIt = 13 : maxItj = 13 |
||
a1 = 1.0 : a2 = 0.0 : d = 0.0 : d1 = 3.2 |
a1 = 1.0 : a2 = 0.0 : d = 0.0 : d1 = 3.2 |
||
Line 241: | Line 241: | ||
a2 = a1 |
a2 = a1 |
||
a1 = a |
a1 = a |
||
next i</ |
next i</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>Same as FreeBASIC entry.</pre> |
<pre>Same as FreeBASIC entry.</pre> |
||
==={{header|Just BASIC}}=== |
==={{header|Just BASIC}}=== |
||
< |
<syntaxhighlight lang="lb">maxit = 13 : maxitj = 13 |
||
a1 = 1.0 : a2 = 0.0 : d = 0.0 : d1 = 3.2 |
a1 = 1.0 : a2 = 0.0 : d = 0.0 : d1 = 3.2 |
||
Line 269: | Line 269: | ||
a2 = a1 |
a2 = a1 |
||
a1 = a |
a1 = a |
||
next i</ |
next i</syntaxhighlight> |
||
==={{header|True BASIC}}=== |
==={{header|True BASIC}}=== |
||
< |
<syntaxhighlight lang="qbasic">LET maxit = 13 |
||
LET maxitj = 13 |
LET maxitj = 13 |
||
LET a1 = 1.0 |
LET a1 = 1.0 |
||
Line 299: | Line 299: | ||
LET a1= a |
LET a1= a |
||
NEXT i |
NEXT i |
||
END</ |
END</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>Same as FreeBASIC entry.</pre> |
<pre>Same as FreeBASIC entry.</pre> |
||
==={{header|Yabasic}}=== |
==={{header|Yabasic}}=== |
||
< |
<syntaxhighlight lang="freebasic">maxIt = 13 : maxItj = 13 |
||
a1 = 1.0 : a2 = 0.0 : d = 0.0 : d1 = 3.2 |
a1 = 1.0 : a2 = 0.0 : d = 0.0 : d1 = 3.2 |
||
Line 326: | Line 326: | ||
a2 = a1 |
a2 = a1 |
||
a1 = a |
a1 = a |
||
next i</ |
next i</syntaxhighlight> |
||
=={{header|C}}== |
=={{header|C}}== |
||
{{trans|Ring}} |
{{trans|Ring}} |
||
< |
<syntaxhighlight lang="c">#include <stdio.h> |
||
void feigenbaum() { |
void feigenbaum() { |
||
Line 358: | Line 358: | ||
feigenbaum(); |
feigenbaum(); |
||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
{{output}} |
{{output}} |
||
Line 379: | Line 379: | ||
=={{header|C sharp|C#}}== |
=={{header|C sharp|C#}}== |
||
{{trans|Kotlin}} |
{{trans|Kotlin}} |
||
< |
<syntaxhighlight lang="csharp">using System; |
||
namespace FeigenbaumConstant { |
namespace FeigenbaumConstant { |
||
Line 409: | Line 409: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 427: | Line 427: | ||
=={{header|C++}}== |
=={{header|C++}}== |
||
{{trans|C}} |
{{trans|C}} |
||
< |
<syntaxhighlight lang="cpp">#include <iostream> |
||
int main() { |
int main() { |
||
Line 454: | Line 454: | ||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 471: | Line 471: | ||
=={{header|D}}== |
=={{header|D}}== |
||
< |
<syntaxhighlight lang="d">import std.stdio; |
||
void main() { |
void main() { |
||
Line 499: | Line 499: | ||
a1 = a; |
a1 = a; |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 517: | Line 517: | ||
=={{header|F#|F sharp}}== |
=={{header|F#|F sharp}}== |
||
{{trans|C#}} |
{{trans|C#}} |
||
< |
<syntaxhighlight lang="fsharp">open System |
||
[<EntryPoint>] |
[<EntryPoint>] |
||
Line 541: | Line 541: | ||
a2 <- a1 |
a2 <- a1 |
||
a1 <- a |
a1 <- a |
||
0 // return an integer exit code</ |
0 // return an integer exit code</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 559: | Line 559: | ||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
{{trans|Raku}} |
{{trans|Raku}} |
||
< |
<syntaxhighlight lang="factor">USING: formatting io locals math math.ranges sequences ; |
||
[let |
[let |
||
Line 583: | Line 583: | ||
exp d "%2d %.8f\n" printf |
exp d "%2d %.8f\n" printf |
||
] each |
] each |
||
]</ |
]</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 602: | Line 602: | ||
=={{header|Fortran}}== |
=={{header|Fortran}}== |
||
< |
<syntaxhighlight lang="fortran"> program feigenbaum |
||
implicit none |
implicit none |
||
Line 631: | Line 631: | ||
print '(i4,f13.10)', i, d1 |
print '(i4,f13.10)', i, d1 |
||
end do |
end do |
||
end</ |
end</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 655: | Line 655: | ||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
< |
<syntaxhighlight lang="freebasic">' version 25-0-2019 |
||
' compile with: fbc -s console |
' compile with: fbc -s console |
||
Line 687: | Line 687: | ||
Print : Print "hit any key to end program" |
Print : Print "hit any key to end program" |
||
Sleep |
Sleep |
||
End</ |
End</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>Feigenbaum constant calculation: |
<pre>Feigenbaum constant calculation: |
||
Line 717: | Line 717: | ||
=={{header|FutureBasic}}== |
=={{header|FutureBasic}}== |
||
{{trans|Ring and Phix}} |
{{trans|Ring and Phix}} |
||
< |
<syntaxhighlight lang="futurebasic"> |
||
window 1, @"Feignenbaum Constant", ( 0, 0, 200, 300 ) |
window 1, @"Feignenbaum Constant", ( 0, 0, 200, 300 ) |
||
Line 751: | Line 751: | ||
HandleEvents |
HandleEvents |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{output}} |
{{output}} |
||
<pre> |
<pre> |
||
Line 773: | Line 773: | ||
=={{header|Go}}== |
=={{header|Go}}== |
||
{{trans|Ring}} |
{{trans|Ring}} |
||
< |
<syntaxhighlight lang="go">package main |
||
import "fmt" |
import "fmt" |
||
Line 799: | Line 799: | ||
func main() { |
func main() { |
||
feigenbaum() |
feigenbaum() |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 821: | Line 821: | ||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
{{trans|Java}} |
{{trans|Java}} |
||
< |
<syntaxhighlight lang="groovy">class Feigenbaum { |
||
static void main(String[] args) { |
static void main(String[] args) { |
||
int max_it = 13 |
int max_it = 13 |
||
Line 849: | Line 849: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 866: | Line 866: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
< |
<syntaxhighlight lang="haskell">import Data.List (mapAccumL) |
||
feigenbaumApprox :: Int -> [Double] |
feigenbaumApprox :: Int -> [Double] |
||
Line 900: | Line 900: | ||
(show <$> feigenbaumApprox 13) |
(show <$> feigenbaumApprox 13) |
||
where |
where |
||
justifyRight n c s = drop (length s) (replicate n c ++ s)</ |
justifyRight n c s = drop (length s) (replicate n c ++ s)</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
<pre> 1 3.2185114220380866 |
<pre> 1 3.2185114220380866 |
||
Line 955: | Line 955: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
{{trans|Kotlin}} |
{{trans|Kotlin}} |
||
< |
<syntaxhighlight lang="java">public class Feigenbaum { |
||
public static void main(String[] args) { |
public static void main(String[] args) { |
||
int max_it = 13; |
int max_it = 13; |
||
Line 983: | Line 983: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 1,000: | Line 1,000: | ||
=={{header|jq}}== |
=={{header|jq}}== |
||
< |
<syntaxhighlight lang="jq">def feigenbaum_delta(imax; jmax): |
||
def lpad: tostring | (" " * (4 - length)) + .; |
def lpad: tostring | (" " * (4 - length)) + .; |
||
def pp(i;x): "\(i|lpad) \(x)"; |
def pp(i;x): "\(i|lpad) \(x)"; |
||
Line 1,024: | Line 1,024: | ||
feigenbaum_delta(13; 10) |
feigenbaum_delta(13; 10) |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<syntaxhighlight lang="sh"> |
|||
<lang sh> |
|||
Feigenbaum's delta constant incremental calculation: |
Feigenbaum's delta constant incremental calculation: |
||
i δ |
i δ |
||
Line 1,042: | Line 1,042: | ||
12 4.669200975097843 |
12 4.669200975097843 |
||
13 4.669205372040318 |
13 4.669205372040318 |
||
</ |
</syntaxhighlight> |
||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
< |
<syntaxhighlight lang="julia"># http://en.wikipedia.org/wiki/Feigenbaum_constant |
||
function feigenbaum_delta(imax=23, jmax=20) |
function feigenbaum_delta(imax=23, jmax=20) |
||
Line 1,068: | Line 1,068: | ||
feigenbaum_delta() |
feigenbaum_delta() |
||
</ |
</syntaxhighlight>{{out}} |
||
<pre> |
<pre> |
||
Feigenbaum's delta constant incremental calculation: |
Feigenbaum's delta constant incremental calculation: |
||
Line 1,099: | Line 1,099: | ||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
{{trans|Ring}} |
{{trans|Ring}} |
||
< |
<syntaxhighlight lang="scala">// Version 1.2.40 |
||
fun feigenbaum() { |
fun feigenbaum() { |
||
Line 1,129: | Line 1,129: | ||
fun main(args: Array<String>) { |
fun main(args: Array<String>) { |
||
feigenbaum() |
feigenbaum() |
||
}</ |
}</syntaxhighlight> |
||
{{output}} |
{{output}} |
||
Line 1,150: | Line 1,150: | ||
=={{header|Lambdatalk}}== |
=={{header|Lambdatalk}}== |
||
Following the Python code in a recursive mode. |
Following the Python code in a recursive mode. |
||
< |
<syntaxhighlight lang="scheme"> |
||
{feigenbaum 11} // on my computer stackoverflow for values greater than 11 |
{feigenbaum 11} // on my computer stackoverflow for values greater than 11 |
||
-> [3.2185114220380866,4.3856775985683365,4.600949276538056,4.6551304953919646,4.666111947822846, |
-> [3.2185114220380866,4.3856775985683365,4.600949276538056,4.6551304953919646,4.666111947822846, |
||
Line 1,183: | Line 1,183: | ||
else {- :a {/ :x :y}} }}} |
else {- :a {/ :x :y}} }}} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
< |
<syntaxhighlight lang="lua">function leftShift(n,p) |
||
local r = n |
local r = n |
||
while p>0 do |
while p>0 do |
||
Line 1,220: | Line 1,220: | ||
a2 = a1 |
a2 = a1 |
||
a1 = a |
a1 = a |
||
end</ |
end</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 1,238: | Line 1,238: | ||
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
||
{{trans|D}} |
{{trans|D}} |
||
< |
<syntaxhighlight lang="mathematica">maxit = 13; |
||
maxitj = 10; |
maxitj = 10; |
||
a1 = 1.0; |
a1 = 1.0; |
||
Line 1,266: | Line 1,266: | ||
, |
, |
||
{i, 2, maxit} |
{i, 2, maxit} |
||
] // Grid</ |
] // Grid</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>2 3.21851 |
<pre>2 3.21851 |
||
Line 1,282: | Line 1,282: | ||
=={{header|Modula-2}}== |
=={{header|Modula-2}}== |
||
< |
<syntaxhighlight lang="modula2">MODULE Feigenbaum; |
||
FROM FormatString IMPORT FormatString; |
FROM FormatString IMPORT FormatString; |
||
FROM LongStr IMPORT RealToStr; |
FROM LongStr IMPORT RealToStr; |
||
Line 1,324: | Line 1,324: | ||
ReadChar |
ReadChar |
||
END Feigenbaum.</ |
END Feigenbaum.</syntaxhighlight> |
||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
{{trans|Kotlin}} |
{{trans|Kotlin}} |
||
< |
<syntaxhighlight lang="nim">import strformat |
||
iterator feigenbaum(): tuple[n: int; δ: float] = |
iterator feigenbaum(): tuple[n: int; δ: float] = |
||
Line 1,357: | Line 1,357: | ||
echo " i δ" |
echo " i δ" |
||
for n, δ in feigenbaum(): |
for n, δ in feigenbaum(): |
||
echo fmt"{n:2d} {δ:.8f}"</ |
echo fmt"{n:2d} {δ:.8f}"</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,375: | Line 1,375: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
< |
<syntaxhighlight lang="perl">use strict; |
||
use warnings; |
use warnings; |
||
use Math::AnyNum 'sqr'; |
use Math::AnyNum 'sqr'; |
||
Line 1,400: | Line 1,400: | ||
($a2, $a1) = ($a1, $a); |
($a2, $a1) = ($a1, $a); |
||
printf "%2d %17.14f\n", $i, $d1; |
printf "%2d %17.14f\n", $i, $d1; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> 2 3.21851142203809 |
<pre> 2 3.21851142203809 |
||
Line 1,417: | Line 1,417: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
{{trans|Ring}} |
{{trans|Ring}} |
||
<!--< |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #008080;">constant</span> <span style="color: #000000;">maxIt</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">13</span><span style="color: #0000FF;">,</span> |
<span style="color: #008080;">constant</span> <span style="color: #000000;">maxIt</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">13</span><span style="color: #0000FF;">,</span> |
||
<span style="color: #000000;">maxItJ</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">10</span> |
<span style="color: #000000;">maxItJ</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">10</span> |
||
Line 1,440: | Line 1,440: | ||
<span style="color: #000000;">a1</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">a</span> |
<span style="color: #000000;">a1</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">a</span> |
||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,460: | Line 1,460: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
{{trans|D}} |
{{trans|D}} |
||
< |
<syntaxhighlight lang="python">max_it = 13 |
||
max_it_j = 10 |
max_it_j = 10 |
||
a1 = 1.0 |
a1 = 1.0 |
||
Line 1,481: | Line 1,481: | ||
d1 = d |
d1 = d |
||
a2 = a1 |
a2 = a1 |
||
a1 = a</ |
a1 = a</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 1,499: | Line 1,499: | ||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
{{trans|C}} |
{{trans|C}} |
||
< |
<syntaxhighlight lang="racket">#lang racket |
||
(define (feigenbaum #:max-it (max-it 13) #:max-it-j (max-it-j 10)) |
(define (feigenbaum #:max-it (max-it 13) #:max-it-j (max-it-j 10)) |
||
(displayln " i d" (current-error-port)) |
(displayln " i d" (current-error-port)) |
||
Line 1,518: | Line 1,518: | ||
(module+ main |
(module+ main |
||
(feigenbaum))</ |
(feigenbaum))</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 1,540: | Line 1,540: | ||
{{trans|Ring}} |
{{trans|Ring}} |
||
<lang |
<syntaxhighlight lang="raku" line>my $a1 = 1; |
||
my $a2 = 0; |
my $a2 = 0; |
||
my $d = 3.2; |
my $d = 3.2; |
||
Line 1,560: | Line 1,560: | ||
($a2, $a1) = ($a1, $a); |
($a2, $a1) = ($a1, $a); |
||
printf "%2d %.8f\n", $exp, $d; |
printf "%2d %.8f\n", $exp, $d; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 1,578: | Line 1,578: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
{{trans|Sidef}} |
{{trans|Sidef}} |
||
< |
<syntaxhighlight lang="rexx">/*REXX pgm calculates the (Mitchell) Feigenbaum bifurcation velocity, #digs can be given*/ |
||
parse arg digs maxi maxj . /*obtain optional argument from the CL.*/ |
parse arg digs maxi maxj . /*obtain optional argument from the CL.*/ |
||
if digs=='' | digs=="," then digs= 30 /*Not specified? Then use the default.*/ |
if digs=='' | digs=="," then digs= 30 /*Not specified? Then use the default.*/ |
||
Line 1,610: | Line 1,610: | ||
/*stick a fork in it, we're all done. */ |
/*stick a fork in it, we're all done. */ |
||
say left('', 9 + 1 + 11 + 1 + t )"↑" /*show position of greatest accuracy. */ |
say left('', 9 + 1 + 11 + 1 + t )"↑" /*show position of greatest accuracy. */ |
||
say ' true value= ' # / 1 /*true value of Feigenbaum's constant. */</ |
say ' true value= ' # / 1 /*true value of Feigenbaum's constant. */</syntaxhighlight> |
||
{{out|output|text= when using the default inputs:}} |
{{out|output|text= when using the default inputs:}} |
||
<pre> |
<pre> |
||
Line 1,641: | Line 1,641: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring"># Project : Feigenbaum constant calculation |
||
decimals(8) |
decimals(8) |
||
Line 1,671: | Line 1,671: | ||
a2 = a1 |
a2 = a1 |
||
a1 = a |
a1 = a |
||
next</ |
next</syntaxhighlight> |
||
Output: |
Output: |
||
<pre>Feigenbaum constant calculation: |
<pre>Feigenbaum constant calculation: |
||
Line 1,690: | Line 1,690: | ||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
{{trans|C#}} |
{{trans|C#}} |
||
< |
<syntaxhighlight lang="ruby">def main |
||
maxIt = 13 |
maxIt = 13 |
||
maxItJ = 10 |
maxItJ = 10 |
||
Line 1,716: | Line 1,716: | ||
end |
end |
||
main()</ |
main()</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 1,734: | Line 1,734: | ||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
===Imperative, ugly=== |
===Imperative, ugly=== |
||
< |
<syntaxhighlight lang="scala">object Feigenbaum1 extends App { |
||
val (max_it, max_it_j) = (13, 10) |
val (max_it, max_it_j) = (13, 10) |
||
var (a1, a2, d1, a) = (1.0, 0.0, 3.2, 0.0) |
var (a1, a2, d1, a) = (1.0, 0.0, 3.2, 0.0) |
||
Line 1,758: | Line 1,758: | ||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
===Functional Style, Tail recursive=== |
===Functional Style, Tail recursive=== |
||
{{Out}}Best seen running in your browser either by [https://scalafiddle.io/sf/OjA3sae/0 ScalaFiddle (ES aka JavaScript, non JVM)] or [https://scastie.scala-lang.org/04eS3BfCShmrA7I8ZmQfJA Scastie (remote JVM)]. |
{{Out}}Best seen running in your browser either by [https://scalafiddle.io/sf/OjA3sae/0 ScalaFiddle (ES aka JavaScript, non JVM)] or [https://scastie.scala-lang.org/04eS3BfCShmrA7I8ZmQfJA Scastie (remote JVM)]. |
||
< |
<syntaxhighlight lang="scala">object Feigenbaum2 extends App { |
||
private val (max_it, max_it_j) = (13, 10) |
private val (max_it, max_it_j) = (13, 10) |
||
Line 1,794: | Line 1,794: | ||
result.foreach { case (δ, i) => println(f"${i + 2}%2d $δ%.8f") } |
result.foreach { case (δ, i) => println(f"${i + 2}%2d $δ%.8f") } |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
{{trans|Raku}} |
{{trans|Raku}} |
||
< |
<syntaxhighlight lang="ruby">var a1 = 1 |
||
var a2 = 0 |
var a2 = 0 |
||
var δ = 3.2.float |
var δ = 3.2.float |
||
Line 1,817: | Line 1,817: | ||
(a2, a1) = (a1, a0) |
(a2, a1) = (a1, a0) |
||
printf("%2d %.8f\n", i, δ) |
printf("%2d %.8f\n", i, δ) |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,841: | Line 1,841: | ||
{{trans|C}} |
{{trans|C}} |
||
< |
<syntaxhighlight lang="swift">import Foundation |
||
func feigenbaum(iterations: Int = 13) { |
func feigenbaum(iterations: Int = 13) { |
||
Line 1,875: | Line 1,875: | ||
} |
} |
||
feigenbaum()</ |
feigenbaum()</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,895: | Line 1,895: | ||
=={{header|Visual Basic .NET}}== |
=={{header|Visual Basic .NET}}== |
||
{{trans|C#}} |
{{trans|C#}} |
||
< |
<syntaxhighlight lang="vbnet">Module Module1 |
||
Sub Main() |
Sub Main() |
||
Line 1,923: | Line 1,923: | ||
End Sub |
End Sub |
||
End Module</ |
End Module</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> i d |
<pre> i d |
||
Line 1,941: | Line 1,941: | ||
=={{header|Vlang}}== |
=={{header|Vlang}}== |
||
{{trans|Go}} |
{{trans|Go}} |
||
< |
<syntaxhighlight lang="vlang">fn feigenbaum() { |
||
max_it, max_itj := 13, 10 |
max_it, max_itj := 13, 10 |
||
mut a1, mut a2, mut d1 := 1.0, 0.0, 3.2 |
mut a1, mut a2, mut d1 := 1.0, 0.0, 3.2 |
||
Line 1,963: | Line 1,963: | ||
fn main() { |
fn main() { |
||
feigenbaum() |
feigenbaum() |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,985: | Line 1,985: | ||
{{trans|Ring}} |
{{trans|Ring}} |
||
{{libheader|Wren-fmt}} |
{{libheader|Wren-fmt}} |
||
< |
<syntaxhighlight lang="ecmascript">import "/fmt" for Fmt |
||
var feigenbaum = Fn.new { |
var feigenbaum = Fn.new { |
||
Line 2,013: | Line 2,013: | ||
} |
} |
||
feigenbaum.call()</ |
feigenbaum.call()</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 2,034: | Line 2,034: | ||
=={{header|zkl}}== |
=={{header|zkl}}== |
||
{{trans|Kotlin}} |
{{trans|Kotlin}} |
||
< |
<syntaxhighlight lang="zkl">fcn feigenbaum{ |
||
maxIt,maxItJ,a1,a2,d1,a,d := 13, 10, 1.0, 0.0, 3.2, 0, 0; |
maxIt,maxItJ,a1,a2,d1,a,d := 13, 10, 1.0, 0.0, 3.2, 0, 0; |
||
println(" i d"); |
println(" i d"); |
||
Line 2,048: | Line 2,048: | ||
d1,a2,a1 = d,a1,a; |
d1,a2,a1 = d,a1,a; |
||
} |
} |
||
}();</ |
}();</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |