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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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 36 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply