Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
pp:l02 [2021/03/13 14:52] pdmatei |
pp:l02 [2021/03/16 19:24] (current) roxana_elena.stiuca [2.3. Strings in Haskell] |
||
---|---|---|---|
Line 14: | Line 14: | ||
2.1.1. Write a function which returns the number of elements from a list. Use patterns. | 2.1.1. Write a function which returns the number of elements from a list. Use patterns. | ||
- | 2.1.2. Write a function which takes a list of integer lists, and concatenates them. (E.g. ''f [[1,2,3],[4,5]] = [1,2,3,4,5]''). | + | 2.1.2. Write a function which takes a list of integer lists, and concatenates them. (E.g. ''f [ [1,2,3],[4,5] ] = [1,2,3,4,5]''). |
2.1.3 (!) Write the **same** function, this time using only the **cons** ('':'') operator as well as **patterns**. | 2.1.3 (!) Write the **same** function, this time using only the **cons** ('':'') operator as well as **patterns**. | ||
Line 85: | Line 85: | ||
<code haskell> | <code haskell> | ||
f [("Dan Matei Popovici",9),("Mihai",4),("Andrei Alex",6)] = | f [("Dan Matei Popovici",9),("Mihai",4),("Andrei Alex",6)] = | ||
- | [(["Dan", "Matei", "Popovici"],10),(["Andrei,Alex"],6)] | + | [(["Dan", "Matei", "Popovici"],10),(["Andrei", "Alex"],6)] |
</code> | </code> | ||