Notes+10.13

Consider Morse code... foreshadowing for an exercise next week: Morse code exercise

Recognizer of Morse code: Usually implemented as a "State Machine". A State Machine is usually drawn on the board as a digraph. The tree diagram in ([]) is almost a State Machine as long as we remember that each node has an exit on observing silence for two extra beats which outputs the letter and returns to the start state. Would it suffice for the start state, upon observing 4 more units of silence, to output a space an loop? I think there needs to be a separate state, splitting the start state in two: one which outputs a space and one which ignores silence. The ignorer would catch long periods of silence over the channel and output nothing. The other one would put spaces between words.

We will discuss State Machines again later.

"Enumeration": originally meant counting. Now also applied to visiting each member of a collection. For example, collecting a phone # from each student. Merely counting items is probably the simplest case. Those who know Smalltalk will recognize

code format="smalltalk" aCollection do: [ :each | each doSomething]

aCollection collect: [ :each | each phoneNumber]

aCollection select: [ :ea | ea somePredicate]

aCollection reject: [ :ea | ea somePredicate]

which is the same as

aCollection select: [ :ea | ea somePredicate not] code "Generic" we'd like to have a generic sorting algorithm which works on what ever kind of data needs sorting. The fairly strong typing of C makes it painful. Other languages allow easier re-use of code.

"Parameter", in a simple form, a parameter is just an argument to a function. A little trickier is a parameter which selects among algorithms.

"Prototype" is "overloaded". It can mean a hand-built model, such as a prototype of a new can opener. In software, a prototype-based system is one where objects get copied to create new objects. The new objects might be incomplete, and need to fill in more information.