]> ocean-lang.org Git - ocean/commitdiff
oceani: cleanup "sayhello" output
authorNeilBrown <neil@brown.name>
Sat, 18 May 2019 15:06:34 +0000 (01:06 +1000)
committerNeilBrown <neil@brown.name>
Sat, 18 May 2019 15:06:34 +0000 (01:06 +1000)
This had become unreadable due to the long arrays.
A few other little cleanups and comments.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/oceani.mdc

index ffa1bbf46e690af76411c61625404a87804c0bfc..a8c7746b8197e59a5a0976315271413cc84a6d64 100644 (file)
@@ -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"