Ulam spiral (for primes): Difference between revisions
m
→{{header|Wren}}: Minor tidy
(Added Easylang) |
m (→{{header|Wren}}: Minor tidy) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1,542:
</pre>
=={{header|EchoLisp}}==▼
The plot libray includes a '''plot-spiral''' function. The nice result is here : [http://www.echolalie.org/echolisp/help.html#plot-spiral EchoLisp Ulam spiral] .▼
<syntaxhighlight lang="scheme">▼
(lib 'plot)▼
(define *red* (rgb 1 0 0))▼
(define (ulam n nmax) (if ( prime? n) *red* (gray (// n nmax))))▼
(plot-spiral ulam 1000) ;; range [0...1000]▼
</syntaxhighlight>▼
=={{header|EasyLang}}==
Line 1,621 ⟶ 1,611:
</syntaxhighlight>
▲=={{header|EchoLisp}}==
▲The plot libray includes a '''plot-spiral''' function. The nice result is here : [http://www.echolalie.org/echolisp/help.html#plot-spiral EchoLisp Ulam spiral] .
▲<syntaxhighlight lang="scheme">
▲(lib 'plot)
▲(define *red* (rgb 1 0 0))
▲(define (ulam n nmax) (if ( prime? n) *red* (gray (// n nmax))))
▲(plot-spiral ulam 1000) ;; range [0...1000]
▲</syntaxhighlight>
=={{header|Elixir}}==
Line 4,538:
=={{header|Quackery}}==
<code>isprime</code> is defined at [[Primality by trial division#Quackery]].▼
<code>spiral</code> is defined at [[Spiral matrix#Quackery]].
▲<code>isprime</code> is defined at [[Primality by trial division#Quackery]].
<syntaxhighlight lang="Quackery">
witheach
[ witheach
[
isprime
{{out}}
<pre>
. . . o . o . . . . . o . . . o . . . . . . . . . .
. . . . . . . . . . . . . . o . . . o . o . . .
. .
. o . o . . . . . o . o . . . . . o
. . . . . . . .
. . . . . o
o . . . o . . . . . . .
. .
. . o . . . . . o . . . o . o . . . . . . . . . . . . .
. . . . . .
o . . . o . . . o . o . . . o . . . . . . . o . . . o .
. . . . . . . . . .
. o . o . o . o . o . o . o . . . o . . . . . . . o
. . . . . . . . . . . . . . o .
. .
. . o . . . . . . . o . o . o . . . . .
. . . . . .
o . . .
. . . o . . . o . . . o . . . . . o . . . .
. . . . . . . . . . . .
. . . . . .
. . . . o . . .
. . . . . o . . . . . o . . . o . o
. o
. o . o . . . . . o . . . .
o . . . . . . . o . . . . . . .
. . . . . . . . . o . o . . . o . o . . . . . . . . . o . . . .
. . . . . . o . . . o . . . . . o . . . . . o . . . . . . . . .
</pre>
Line 5,805:
{{libheader|Wren-str}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="
import "./math" for Int
import "./str" for Char
import "./fmt" for Fmt
var Direction = Enum.create("Direction", ["right", "up", "left", "down"])
|