Page 1 of 1

1-) data Direction = North | East | South West deriving (Show) data Robot Rover Direction Integer | Survey Integer [(Int

Posted: Thu May 05, 2022 12:41 pm
by answerhappygod
1 Data Direction North East South West Deriving Show Data Robot Rover Direction Integer Survey Integer Int 1
1 Data Direction North East South West Deriving Show Data Robot Rover Direction Integer Survey Integer Int 1 (461.43 KiB) Viewed 35 times
1-) data Direction = North | East | South West deriving (Show) data Robot Rover Direction Integer | Survey Integer [(Integer, String)] deriving (Show) artoo, hal :: Robot artoo = Survey 7 [(5,"dune"), (18,"swamp"), (25, "plans")] hal = Survey 0 [(3,"pod"), (-6,"bay")] pool, group: [Robot] pool [Rover East 10, Rover South 4, Survey 8 [(1,"")], Rover North 5] group = [Rover North 5, Rover West 17] For each case below, determine what happens in an attempt to match the pattern with the indicated data. • If the data fails to match the pattern for any reason, then write No match and briefly explain why the pattern match fails. If the data matches the pattern, then give the resulting value for the indicated name/variable. 1. Pattern: (_:w:g) Data: pool Give the resulting value for w. 2. Pattern: (Rover k v, m) Data: group Give the resulting value for m. 3. Pattern: (Survey n (a: (b, c):_)) Data: artoo Give the resulting value for b. 4. Pattern: ye(t:d) Data: [Rover West 3, Rover South 63] Give the resulting value for d.
5. Pattern: ((Survey i z):q) Give the resulting value for q. 6. Pattern: (_:_:u) Give the resulting value for u. Data: hal Data: group