Created
September 30, 2018 21:37
-
-
Save faiface/25896a033a04c022af82e5c244970fb3 to your computer and use it in GitHub Desktop.
functional or imperative?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
record Vars = | |
count : Int, | |
sum : Int, | |
func initial-vars : Vars = Vars 0 0 | |
func main : IO = | |
start-with initial-vars; | |
count := 0; | |
sum := 0; | |
fix \loop | |
retreat \vars | |
println ("count: " ++ string (count vars)); | |
println ("sum: " ++ string (sum vars)); | |
print "type a word: "; | |
scanln \word | |
start-with vars; | |
if (word == ":reset") ( | |
count := 0; | |
sum := 0; | |
loop | |
); | |
count <- inc; | |
sum <- + length word; | |
loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment