From c88ee43ddbf90b66c05cec850b9f3a138d8da7ec Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 19 May 2019 01:06:34 +1000 Subject: [PATCH] oceani: cleanup "sayhello" output This had become unreadable due to the long arrays. A few other little cleanups and comments. Signed-off-by: NeilBrown --- csrc/oceani.mdc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index ffa1bbf..a8c7746 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -4182,7 +4182,7 @@ Fibonacci, and performs a binary search for a number. program A B: print "Hello World, what lovely oceans you have!" - print "are there", five, "?" + print "Are there", five, "?" print pi, pie, "but", cake /* When a variable is defined in both branches of an 'if', @@ -4251,16 +4251,19 @@ Fibonacci, and performs a binary search for a number. case GiveUp: print "Closest I found was", mid - size::=55 + size::= 10 list:[size]number list[0] = 1234 + // "middle square" PRNG. Not particularly good, but one my + // Dad taught me - the first one I ever heard of. for i:=1; then i = i + 1; while i < size: n := list[i-1] * list[i-1] list[i] = (n / 100) % 10000 - print "Before sort:" + print "Before sort:", for i:=0; then i = i + 1; while i < size: - print "list[",i,"]=",list[i] + print "", list[i], + print for i := 1; then i=i+1; while i < size: for j:=i-1; then j=j-1; while j >= 0: @@ -4268,11 +4271,12 @@ Fibonacci, and performs a binary search for a number. t:= list[j] list[j] = list[j+1] list[j+1] = t - print "After sort:" + print " After sort:", for i:=0; then i = i + 1; while i < size: - print "list[",i,"]=",list[i] + print "", list[i], + print bob:fred bob.name = "Hello" bob.alive = (bob.name == "Hello") - print bob.alive + print "bob", "is" if bob.alive else "isn't", "alive" -- 2.43.0