6.01 Lecture Notes - Lecture 15: List Comprehension, Combinatory Logic, Modus Operandi

7 views11 pages

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.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions