1. Engineering
  2. Computer Science
  3. 2 2 pts recall that parameter specifications in function definitions...

Question: 2 2 pts recall that parameter specifications in function definitions...

Question details

2. (2 pts) Recall that parameter specifications in function definitions come in two flavors: name-only parameters and default-argument parameters, with the ability to preface at most one name-only parameter by a *(for this problem, we will not allow ** written before a name-only parameter, although such parameters are legal in Python). All parameters are separated by commas. To simplify this problem, lets use n to abbreviate a name-only parameter and d to abbreviate a default-argument parameter. Write a regular-expression pattern that matches legal orders of these parameter lists in a function definition. The general rule you should model is: a parameter list can (a) be empty, (b) contain one n, n, or d, (c) can contain a sequence of ns and ds with at most one *n in the sequence (front, middle, or rear). Legal: Should Match:n; d: *n; n,d.n,d; n,d, *n,d,d; ; n,d.d,n.d; n,n, *n Illegal: Should Not Match: nd; *n, *n; n, *nd; n,d*n,d; *n,d,d, *n

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution