Difference between revisions of "FP Laboratory 3"
Jump to navigation
Jump to search
(Created page with "== Simple functions working with list == Implement following functions: * Create a function that computes length of a list. <syntaxhighlight lang="Haskell">length :: [a] -> I...") |
|||
Line 6: | Line 6: | ||
* Create a function that sums the list of integers. | * Create a function that sums the list of integers. | ||
<syntaxhighlight lang="Haskell">sumIt :: [Int] -> Int</syntaxhighlight> | <syntaxhighlight lang="Haskell">sumIt :: [Int] -> Int</syntaxhighlight> | ||
+ | * Create a function that returns the first element in the list. | ||
+ | <syntaxhighlight lang="Haskell">getHead :: [a] -> a</syntaxhighlight> | ||
+ | * Create a function that returns the last element in the list. | ||
+ | <syntaxhighlight lang="Haskell">getLast :: [a] -> a</syntaxhighlight> | ||
+ | * Create a function that returns the list without the first element. | ||
+ | <syntaxhighlight lang="Haskell">getTail :: [a] -> [a]</syntaxhighlight> | ||
+ | * Create a function that returns the list without the last element. | ||
+ | <syntaxhighlight lang="Haskell">getInit :: [a] -> [a]</syntaxhighlight> | ||
* Create a function that merge two lists into one list. | * Create a function that merge two lists into one list. | ||
<syntaxhighlight lang="Haskell">combine :: [a] -> [a] -> [a]</syntaxhighlight> | <syntaxhighlight lang="Haskell">combine :: [a] -> [a] -> [a]</syntaxhighlight> |
Revision as of 10:56, 17 September 2019
Simple functions working with list
Implement following functions:
- Create a function that computes length of a list.
length :: [a] -> Int
- Create a function that sums the list of integers.
sumIt :: [Int] -> Int
- Create a function that returns the first element in the list.
getHead :: [a] -> a
- Create a function that returns the last element in the list.
getLast :: [a] -> a
- Create a function that returns the list without the first element.
getTail :: [a] -> [a]
- Create a function that returns the list without the last element.
getInit :: [a] -> [a]
- Create a function that merge two lists into one list.
combine :: [a] -> [a] -> [a]
- Create a function that reverse a list.
reverse :: [a] -> [a]
- Create a function that merge two lists into one list.
combine :: [a] -> [a] -> [a]
- Create a function that product scalar multiplication if two vectors.
scalar :: [Int] -> [Int] -> Int
- Create a function that find the smallest element in the list. Consider input restrictions.
minimum :: [a] -> a -- Is this right?
- Find all prime divisors of a given number.
divisors :: a -> [a]