Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
fp:exam2021:l2 [2021/06/03 13:14] pdmatei |
fp:exam2021:l2 [2021/06/03 15:43] (current) pdmatei |
||
---|---|---|---|
Line 3: | Line 3: | ||
1. (2p) Write a function in Haskell which extracts all **even** positions from a list. Example ''f [1,2,3,4,5] = [1,3,5]'' | 1. (2p) Write a function in Haskell which extracts all **even** positions from a list. Example ''f [1,2,3,4,5] = [1,3,5]'' | ||
- | 2. (2p) Write a function which removes those strings from a list, which are not in the date format. A correct date format is considered: ''DD.MM.YYYY'' where D,M,Y can be any digit. | + | 2. (2p) Write a function which takes a list of pairs ''Name-Age'' and returns the average age of names called ''Ana''. |
3. (2p) Implement an Algebraic datatype which encodes **semaphores**. A **semaphore** has a color (red, green, yellow). Write a function which checks if a list of semaphores is synchronised (all semaphores have the same color). | 3. (2p) Implement an Algebraic datatype which encodes **semaphores**. A **semaphore** has a color (red, green, yellow). Write a function which checks if a list of semaphores is synchronised (all semaphores have the same color). | ||
- | 4. (1p) Suppose | + | 4. (1p) Consider a 8x8 chessboard which contains only rooks, encoded as a matrix. The presence of a rook on a position is encoded by the character 'R'. The character ' ' encodes a free position. Write a function which takes a chessboard and returns true if two rooks attack each other. |
- | Example: | + | |
- | <code haskell> | + | |
- | .*. | + | |
- | img = **. | + | |
- | ... | + | |
- | .*..*..*. | + | |
- | **.**.**. | + | |
- | ......... | + | |
- | .*..*..*. | + | |
- | tile 3 img = **.**.**. | + | |
- | ......... | + | |
- | .*..*..*. | + | |
- | **.**.**. | + | |
- | ......... | + | |
- | </code> |