6.01 Lecture Notes - Lecture 15: List Comprehension, Combinatory Logic, Modus Operandi
Document Summary
155 takes a string as input, and returns a sequential tsm that will output that string. It uses a list comprehension to turn each character into a chartsm that generates that character, and then uses that sequence to make a sequence. def maketextsequencetsm(str): return sm. sequence([chartsm(c) for c in str]) In: none out: h next state: (1, false) In: none out: e next state: (2, false) In: none out: l next state: (3, false) In: none out: l next state: (4, false) In: none out: o next state: (5, false) In: none out: w next state: (7, false) In: none out: o next state: (8, false) In: none out: r next state: (9, false) In: none out: l next state: (10, false) In: none out: d next state: (10, true) ["h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"] We can also see that sequencing interacts well with the repeat combinator.