Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| fp:lab09 [2021/05/13 14:50] pdmatei | fp:lab09 [2021/05/13 17:39] (current) pdmatei | ||
|---|---|---|---|
| Line 37: | Line 37: | ||
| 9.1.3. Implement the ADT of an ID, where an ID may be defined as: | 9.1.3. Implement the ADT of an ID, where an ID may be defined as: | ||
| - | - a CNP (Personal Identification Number). In Romania, the CNP has the following structure: ''SDDMMYYXXXXXX'' where: | + | * a CNP (Personal Identification Number). In Romania, the CNP has the following structure: ''SDDMMYYXXXXXX'' where: | 
| - ''S'' is the **gender** and **birth-period** digit: | - ''S'' is the **gender** and **birth-period** digit: | ||
| - ''S=1'' - male born before year ''2000'' | - ''S=1'' - male born before year ''2000'' | ||
| Line 46: | Line 46: | ||
| - ''XXXXXX'' - the last six digits encode other info which are not relevant for us. | - ''XXXXXX'' - the last six digits encode other info which are not relevant for us. | ||
| or | or | ||
| - | + | * a collection of strings which represent: | |
| - | - a collection of strings which represent: | + | |
| - Full name | - Full name | ||
| - Complete year of birth | - Complete year of birth | ||
| - gender (''male'' or ''female'') | - gender (''male'' or ''female'') | ||
| - | * Implement the type ''Gender'' (it is better to define a gender separately, instead of using True/False or strings, because it reduces the occurrence of bugs). | + | * Implement the type ''Gender'' (it is better to define a gender separately, instead of using True/False or strings, because it reduces the occurrence of bugs). | 
| - | * Implement a function which takes a gender, a list of ID's and returns those having that gender (you can safely assume that the CNP has valid form. **Hint:** use functional closures and higher-order functions). | + | * Implement a function which takes a gender, a list of ID's and returns those having that gender (you can safely assume that the CNP has valid form. **Hint:** use functional closures and higher-order functions). | 
| <code haskell> | <code haskell> | ||
| Line 65: | Line 64: | ||
| </code> | </code> | ||
| - | 9.1.5. (**Optional**) Define an ADTs called ''Range'', which encodes a **range** of birth years together with a gender. For instance: | + | 9.1.5. Define an ADTs called ''Range'', which encodes a **range** of birth years together with a gender. For instance: | 
| - one range could designate people of gender //female// born between 1956 and 2005 | - one range could designate people of gender //female// born between 1956 and 2005 | ||
| - another range could designate both //male// and //female// born between 1991 and 2006 | - another range could designate both //male// and //female// born between 1991 and 2006 | ||