BiGram で隣接する二文字を抽出する際に用いるのと同じ機構を使った版
| series dict size stream newline lines yy up down |
series := 'RCRFCRFFCCRFFRRCRRCCFRFRFF'.
dict := {$R -> $/. $F -> $\. $C -> $_} as: Dictionary.
size := series size.
stream := series readStream.
newline := String new: size withAll: Character space.
lines := OrderedCollection with: newline copy.
lines first at: 1 put: (dict at: stream peek).
yy := 1.
up := [yy = 1 ifTrue: [lines addFirst: newline copy] ifFalse: [yy := yy - 1]].
down := [yy = lines size ifTrue: [lines addLast: newline copy]. yy := yy + 1].
[stream position + 1 < size] whileTrue: [
| pair |
pair := stream next: 2.
(#('RR' 'RC') includes: pair) ifTrue: [up value].
(#('FF' 'CF') includes: pair) ifTrue: [down value].
(lines at: yy) at: stream position put: (dict at: pair last).
stream back].
World findATranscript: nil.
lines do: [:line | Transcript cr; show: line]