Week 10 Flashcards
What comes in to the uniq program?
Either stdin or a file. Both treated the same once the file is open
Filename is identified as the sole parameter that uniq might accept
What transformations do I need to make to the data in the uniq program?
No changes needed to the data
What part of the data is processed right away?
I can print each line of text if it is different from the preceding line
What part of the data do I need to keep longer?
I need to remember the last processed line of the file
I need to compare that line with a new line
What goes out of the program?
All output to stout. Print each line that isn’t the same as the one before.
Uniq program: What assumptions can I make?
Are any given? Zero or one arguments of the program. Problem speaks of lines of the file, so we’ll infer line-based text input.
Uniq program: Can I reasonably make any of my own assumptions?
Maximum line length. Set to 80 characters.
All characters will be printable.
What constraints exist for uniq program?
Full program in C
Are there strange cases to handle in uniq program?
Empty file
One line in the file (so nothing to compare against)
What is important for the solution to do for uniq?
Single-pass of the file so hat it can be used with a pipe if necessary.