Difference between revisions of "Activity assignment 1"
Jump to navigation
Jump to search
Line 3: | Line 3: | ||
Implement following functions. There will be 5 points for each of these functions. | Implement following functions. There will be 5 points for each of these functions. | ||
− | Create a function that gets a list of tuples (Int, Char). This function takes these | + | * Create a function that gets a list of tuples - <code>[(Int, Char)]</code>. This function takes these pairs and for each of these pairs <code>(n, a)</code> generates a string where the character <code>a</code> is multiplied <code>n</code> times. The function result is a concatenation of these sub-strings. |
− | |||
<syntaxhighlight lang="Haskell" > | <syntaxhighlight lang="Haskell" > | ||
create :: [(Int, Char)] -> String | create :: [(Int, Char)] -> String | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
<syntaxhighlight lang="Haskell" class="myDark" > | <syntaxhighlight lang="Haskell" class="myDark" > | ||
create [(2,'a'), (3,'B')] = "aaBBB" | create [(2,'a'), (3,'B')] = "aaBBB" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | * Create |
Revision as of 10:12, 11 November 2019
Activity assignments
Implement following functions. There will be 5 points for each of these functions.
- Create a function that gets a list of tuples -
[(Int, Char)]
. This function takes these pairs and for each of these pairs(n, a)
generates a string where the charactera
is multipliedn
times. The function result is a concatenation of these sub-strings.
create :: [(Int, Char)] -> String
create [(2,'a'), (3,'B')] = "aaBBB"
- Create