Skip to content

Instantly share code, notes, and snippets.

@faiface
Created September 30, 2018 21:37
Show Gist options
  • Save faiface/25896a033a04c022af82e5c244970fb3 to your computer and use it in GitHub Desktop.
Save faiface/25896a033a04c022af82e5c244970fb3 to your computer and use it in GitHub Desktop.
functional or imperative?
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