Inital commit +

Added recursive counting loop and first list access
main
Victor Hans-Georg Waitz 2024-11-22 02:31:04 +01:00
commit 7619f83c79
1 changed files with 55 additions and 0 deletions

55
main.roc 100644
View File

@ -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))