aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/mandelbrot.sloth22
-rw-r--r--examples/mergesort.sloth4
2 files changed, 15 insertions, 11 deletions
diff --git a/examples/mandelbrot.sloth b/examples/mandelbrot.sloth
index bc95e2f..fb22b88 100644
--- a/examples/mandelbrot.sloth
+++ b/examples/mandelbrot.sloth
@@ -1,23 +1,23 @@
-val size: int = 200;
-val maxVal: float = 4.0;
-val maxIter: int = 50;
-val plane: float = 4.0;
+val size: Int = 200;
+val maxVal: Float = 4.0;
+val maxIter: Int = 50;
+val plane: Float = 4.0;
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;
+ 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;
+ var temp: Float = (zReal * zReal) - (zImg * zImg) + cReal;
zImg = 2 * zReal * zImg + cImg;
zReal = temp;
count += 1;
}
if count == maxIter {
- term_setpos(x, y);
+ termpos(x, y);
print("*");
}
}
diff --git a/examples/mergesort.sloth b/examples/mergesort.sloth
new file mode 100644
index 0000000..f1e5901
--- /dev/null
+++ b/examples/mergesort.sloth
@@ -0,0 +1,4 @@
+fn merge_sort(list: List<Int>) {
+ print(list);
+
+}