Class 29 — Wednesday April 1

Functionization

Social distancing — Does not mean we cannot share — Love, hopes, and friendship

It's April Fools Day — I am sorry for past pranks — And those yet to come


Look both ways


Zoom


Download now


Download when asked


The teaching assistant staff


All members of the CS 1112 community — students and staff


Agenda


To Do


Some scary datasets


Test 2


Function separate( s )

s1 = "apple"

s2 = "banana"

s3 = "1"

s4 = ""

separate( s1 ): ['a', 'p', 'p', 'l', 'e']

separate( s2 ): ['b', 'a', 'n', 'a', 'n', 'a']

separate( s3 ): ['1']

separate( s4 ): []



Function join( sl )

sl1 = ['a', 'p', 'p', 'l', 'e']

sl2 = [ 'wa', 'hoo', 'wa ' ]

join( sl1 ): 'a p p l e'

join( sl2 ): 'wa hoo wa '



Function ints( ns )

b1 = "abc"

b2 = "3 def 4 ghi"

b3 = "3.14"

ns1 = " 3 "

ns2 = "12 11 -63"

ns3 = "31 415 92 653 5 9"

ns4 = " "

ints( ns1 ): [3]

ints( ns2 ): [12, 11, -63]

ints( ns3 ): [31, 415, 92, 653, 5, 9]

ints( ns4 ): []



Function parse_phone_string( pn )

pn1 = "(201) 867-5309"

pn5 = "8602941986"

pn3 = "21 25 55 2368"

pn4 = "888.799.9666"

parse_phone_string( pn1 ): [201, 867, 5309]

parse_phone_string( pn2 ): [860, 294, 1986]

parse_phone_string( pn3 ): [212, 555, 2368]

parse_phone_string( pn4 ): [888, 799, 9666]



Suppose the following constants are in effect

PUNCTUATION = '''!"#$%&'()*+,-./:;<=>?@[]^_`{|}~'''

WHITE_SPACE = ' \t\n\r\v\f'

EXTRANEOUS = PUNCTUATION + WHITE_SPACE



Suppose the following test case variable definitions are in effect

test1 = ['AbCdE', 'ABCDE', '!"#x$&)|}~', '- x -_', 'AAcc', ' ', 'x\n']

test2 = ['\tx X']

test3 = []

test4 = ['a', 'B', 'r', 'A', 'c', 'a', 'D', 'a', 'B', 'r', 'a']



Function canonical( strings )

canonical( test1 ) = ['abcde', 'x', 'aacc', '']

canonical( test2 ) = ['x x']

canonical( test3 ) = []

canonical( test4 ) = ['a', 'b', 'r', 'c', 'd']



Function lower( strings )

lower( test1 ) = ['abcde', 'abcde', '!"#x$&)|}~', '- x -_', 'aacc', ' ', 'x\n']

lower( test2 ) = ['\tx x']

lower( test3 ) = []

lower( test4 ) = ['a', 'b', 'r', 'a', 'c', 'a', 'd', 'a', 'b', 'r', 'a']



Function strip( strings )

strip( test1 ) = ['AbCdE', 'ABCDE', 'x', 'x', 'AAcc', '', 'x']

strip( test2 ) = ['x X']

strip( test3 ) = []

strip( test4 ) = ['a', 'B', 'r', 'A', 'c', 'a', 'D', 'a', 'B', 'r', 'a']



Function unique( strings )

unique( test1 ) = ['AbCdE', 'ABCDE', '!"#x$&)|}~', '- x -_', 'AAcc', ' ', 'x\n']

unique( test2 ) = ['\tx X']

unique( test3 ) = []

unique( test4 ) = ['a', 'B', 'r', 'A', 'c', 'D']




Maria Saal Dom Grabbaurelief Reisewagen in die Unterwelt

 


 
  © 2020 Jim Cohoon   Resources from previous semesters are available.