aboutsummaryrefslogtreecommitdiff
path: root/examples/mandelbrot.sloth
diff options
context:
space:
mode:
authornic-gaffney <gaffney_nic@protonmail.com>2023-06-26 21:29:43 -0500
committernic-gaffney <gaffney_nic@protonmail.com>2023-06-26 21:29:43 -0500
commit8c9bd55e161ba5fcaea626a1db2e0b685ac4f096 (patch)
tree998dba9c480ca1342b3bf5d4fd418848577ac563 /examples/mandelbrot.sloth
parent54a2023adac82dc2d25c7de3eb5c5d54a9c0e83a (diff)
downloadsloth-8c9bd55e161ba5fcaea626a1db2e0b685ac4f096.tar.gz
added vim highlighting
Diffstat (limited to 'examples/mandelbrot.sloth')
-rw-r--r--examples/mandelbrot.sloth50
1 files changed, 30 insertions, 20 deletions
diff --git a/examples/mandelbrot.sloth b/examples/mandelbrot.sloth
index fb22b88..f9ebdc8 100644
--- a/examples/mandelbrot.sloth
+++ b/examples/mandelbrot.sloth
@@ -1,24 +1,34 @@
-val size: Int = 200;
-val maxVal: Float = 4.0;
-val maxIter: Int = 50;
-val plane: Float = 4.0;
+foreign fn termpos(x: Int, y: Int);
+foreign fn print(str: String);
-for x in 0 .. size {
- for y in 0 .. size {
- var cReal: Float = (x * plane / size) - 2;
- var cImg: Float = (y * plane / size) - 2;
- var zReal: Float = 0;
- var zImg: Float = 0;
- var count: Float = 0;
- while (zReal * zReal + zImg * zImg) <= maxVal && count < 4{
- var temp: Float = (zReal * zReal) - (zImg * zImg) + cReal;
- zImg = 2 * zReal * zImg + cImg;
- zReal = temp;
- count += 1;
- }
- if count == maxIter {
- termpos(x, y);
- print("*");
+fn main() Int{
+ var size: Float = 200.0;
+ var maxVal: Float = 4.0;
+ var maxIter: Int = 50;
+ var plane: Float = 4.0;
+ # lmao
+ var x: Int = 0;
+ while x < size {
+ var y: Int = 0;
+ while y < size {
+ var cReal: Float = (x * plane / size) - 2.0;
+ var cImg: Float = (y * plane / size) - 2.0;
+ var zReal: Float = 0.0;
+ var zImg: Float = 0.0;
+ var count: Int = 0;
+ while (zReal * zReal + zImg * zImg) <= maxVal && count < 4{
+ var temp: Float = (zReal * zReal) - (zImg * zImg) + cReal;
+ zImg = 2.0 * zReal * zImg + cImg;
+ zReal = temp;
+ count = count + 1;
+ }
+ if count == maxIter {
+ termpos(x, y);
+ print("*");
+ }
+ y = y + 1;
}
+ x = x + 1;
}
+ return 0;
}