aboutsummaryrefslogtreecommitdiff
path: root/examples/fib.sloth
diff options
context:
space:
mode:
Diffstat (limited to 'examples/fib.sloth')
-rw-r--r--examples/fib.sloth90
1 files changed, 0 insertions, 90 deletions
diff --git a/examples/fib.sloth b/examples/fib.sloth
deleted file mode 100644
index 9b0cee9..0000000
--- a/examples/fib.sloth
+++ /dev/null
@@ -1,90 +0,0 @@
-fn fib(n: i32): i32 {
- val msg = if (n == 0) "No points" else "Some points"
- val msg = if n == 0 { "No points" } else { "Some points" }
- val msg = if n == 0: "No points" else: "Some points"
-
- if n == 0 || n == 1 {
- return n;
- }
-
- var grandparent = 0;
- var parent = 1;
- var me = 0;
-
- for i in 0..n-1 {
- me = parent + grandparent;
- grandparent = parent;
- parent = me;
- }
-
- return me;
-}
-
-pub type Button = {
- pub x: i32,
- pub y: i32,
- text: String,
-}
-
-impl Button {
- fn init(text) {
- return Self(
- x: 50,
- y: 150,
- text, # Pass in text
- )
- }
-}
-
-impl Constructor for Button {
- fn init(text) {
- Self(
- x: 50,
- y: 150,
- text, # Pass in text
- )
- }
-}
-
-Button::init("Hello")
-Button("Hello")
-
-print(fib(0));
-print(fib(1));
-print(fib(2));
-print(fib(3));
-print(fib(4));
-print(fib(5));
-
-# Inferred as List
-val nums = read("input.txt")
- .lines()
- .filter(-> /$[0-9]+^/ in $0)
- .collect()
-
-fn T <- From<Self> = List collect(self): T {
-
-}
-
-fn collect(self): 'a
-where
- 'a : From<Self>, # Type Constraints
- 'a = List, # Generic Defaults
- 'a : From<Self> = List, # Combined
-{
- #
-}
-
-# This following code should
-fn add(lhs, rhs) {
- return lhs + rhs;
-}
-
-# Ideally infer to
-fn add(lhs: 'a, rhs: 'b): 'c
-where
- 'a : Add<'b, 'c>,
- 'b = 'a,
-{
- return lhs + rhs;
-}