Notes+10.18

A book, when someone is using it, might have a bookmark. Pulling out someone's bookmark loses their information. Matt is a good sport about it: I trust he will be able to find his place in Calculus.

A simple representation of text is a String, or an array of char's in C. When a program processes a text, it typically goes through characters sequentially. Bundle the concept of a position in the string with the string. The result is often called a Stream. I swear I have seen ReadStream and WriteStream implemented in C, and the familiar FILE * named stdin and stdout act as Streams. I suggest you implement Streams and use them if you want to operate on strings in memory. Code which looks like code for(ix=0; (ch = aString[ix]) != '\0'; ix++) { . . .       // Don't you dare mess with ix    }

code seems to break easily. If loops get nested, the intention can be obscured. People are tempted to diddle with the index variable. Don't. code while (ch = nextChar(aStream)) { // Notice that you don't even SEE an index variable }

code Foreshadowing Objects, it is not nice to just reach in and give your Stream a wedgie. It is also not smart. Access a Stream through simple functions with mnemonic names. You can define those.

I showed a few puzzles... some of them computed factorials. Did you see how soon factorial stopped being accurate?

Havvy and Bob showed their JavaScript implementation of SortedCollection.