-
Notifications
You must be signed in to change notification settings - Fork 5
/
playground.txt
65 lines (57 loc) · 1.02 KB
/
playground.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
title: Playground
description: Playground for running Myrddin Source
}
### Code
```{runmyr mandelbrot}
use std
use bio
/* Controls when we finish the iterations */
const Bailout : flt64 = 16.0
const Maxiter = 1000
const main = {args : byte[:][:]
/* Declarations with types */
var x : flt64, y : flt64, i, f
/* create a buffered wrapper for stdio */
f = bio.mkfile(1, bio.Wr)
/* iterate over the range of interest, and draw the fractal */
for y = -39.0; y < 39.0; y = y + 1.0
for x = -39.0; x < 39.0; x = x + 1.0
i = mandelbrot(x/40.0, y/40.0)
if i == 0
bio.putc(f, '*')
else
bio.putc(f, ' ')
;;
;;
bio.putc(f, '\n')
;;
bio.putc(f, '\n')
bio.flush(f)
}
const mandelbrot = {x, y
var cr, ci, zr, zi
var tmp, zr2, zi2
var i : int
cr = y - 0.5
ci = x
zr = 0.0
zi = 0.0
i = 0
while true
i++
tmp = zr * zi
zr2 = zr * zr
zi2 = zi * zi
zr = zr2 - zi2 + cr
zi = tmp + tmp + ci
if zi2 + zr2 > Bailout
-> i
;;
if i > Maxiter
-> 0
;;
;;
std.die("unreachable")
}
```