Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
lfa:lab02-dfa [2021/10/07 10:46] pdmatei |
lfa:lab02-dfa [2021/10/13 16:13] (current) ioana.georgescu [Classes in Python] |
||
|---|---|---|---|
| Line 10: | Line 10: | ||
| class Example: | class Example: | ||
| # the class constructor. | # the class constructor. | ||
| - | def __init___(self,param1,param2): | + | def __init__(self,param1,param2): |
| # the keyword self is similar to this from Java | # the keyword self is similar to this from Java | ||
| # it is the only legal mode of initialising and referring class member variables | # it is the only legal mode of initialising and referring class member variables | ||
| Line 62: | Line 62: | ||
| where: | where: | ||
| - | - the initial state is given on the first line of the input | + | * the initial state is given on the first line of the input |
| - | - each of the subsequent lines encode transitions (states are integers) | + | * each of the subsequent lines encode transitions (states are integers) |
| - | - the last line encodes the set of final states. | + | * the last line encodes the set of final states. |
| Example: | Example: | ||
| Line 118: | Line 118: | ||
| ---- | ---- | ||
| - | **2.2.2.** Define a function which takes a string of the following form showed below, and returns a DFA: | + | **2.2.2.** Define a function which takes a string of the following form showed below, and returns a DFA **with states as integers**: |
| <code> | <code> | ||
| <initial_state> | <initial_state> | ||
| Line 128: | Line 128: | ||
| where: | where: | ||
| - | - the initial state is given on the first line of the input | + | * the initial state is given on the first line of the input |
| - | - each of the subsequent lines encode transitions (states are integers) | + | * each of the subsequent lines encode transitions (states are integers) |
| - | - the last line encodes the set of final states. | + | * the last line encodes the set of final states. |
| Example: | Example: | ||
| Line 140: | Line 140: | ||
| 1 2 | 1 2 | ||
| </code> | </code> | ||
| + | |||
| + | **Hint:** Use ''splitBy'' from PP. | ||
| ---- | ---- | ||
| Line 147: | Line 149: | ||
| **2.2.4.** Implement function which takes a DFA and a **configuration** (pair of state and rest of word) and returns the next configuration. | **2.2.4.** Implement function which takes a DFA and a **configuration** (pair of state and rest of word) and returns the next configuration. | ||
| - | **2.2.5.** Implement a function which verifies if a word is **accepted** by a Dfa. | + | **2.2.5.** Implement a function which verifies if a word is **accepted** by a Dfa. What kind of general list-operation best matches the accepting process? |