commit 7619f83c7978cbcfa8f291f5e7ff643de2772335 Author: 3013050 <3013050@stud.hs-mannheim.de> Date: Fri Nov 22 02:31:04 2024 +0100 Inital commit + Added recursive counting loop and first list access diff --git a/main.roc b/main.roc new file mode 100644 index 0000000..806be04 --- /dev/null +++ b/main.roc @@ -0,0 +1,55 @@ +app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.16.0/O00IPk-Krg_diNS2dVWlI0ZQP794Vctxzv0ha96mK0E.tar.br" } + +import pf.Stdout + +# listLen = \list -> +# List.len (list) + + +# sumList = \counter, maxLen -> +# if counter == maxLen then +# 1 +# else +# newCounter = counter + 1 +# ((sumList newCounter maxLen) + 1) + +sumList : Num *, Num * -> Num * + +sumList = \counter, maxLen -> + if counter == maxLen then + 1 + else + newCounter = counter + 1 + ((sumList newCounter maxLen) + 1) + +plusTwo: Num a -> Num a +plusTwo = \i -> + i + 2 + +main = + sum = sumList 0 7 + Stdout.line! (Num.toStr(sum)) + + # nums = [1, 2, 3] + # ind = 1 + # res = List.get nums ind + + # when res is + # Ok value -> value + # Err OutOfBounds -> 0 + + i = plusTwo 4 + Stdout.line! (Num.toStr(i)) + + + + + # sum = sumList(0, 4) + # #Stdout.line! (Num.toStr(sumList 2, 3)) + # Stdout.line! (sum) + # gomus = [1, 2, 3] + # gomusLen = List.len( gomus ) + # Stdout.line! (Num.toStr(gomusLen)) + + +