Webpage of the Compositional Systems and Methods group at TalTech.
myReverse: List ty -> List ty
that reverses lists.
myReverse [1,2,3] == [3,2,1]
revString: String -> String
that reverses
strings. You may find the Prelude functions unpack: String ->
List Char
and its inverse pack
useful.
revString "hello" == "olleh"
palindrome: String -> Bool
that tests
whether a string is a palindrome.
palindrome "idris" == False
palindrome "idrisirdi" == True
myCycle: List ty -> Nat -> List ty
that takes
a list and repeats it the required number of times.
myCycle ['a', 'b'] 3 == ['a', 'b', 'a', 'b', 'a', 'b']
deal: List ty -> (List ty, List ty)
that
splits a list into two lists, containing its even and odd
elements. You may find it useful to start by writing functions odds:
List ty -> List ty
and evens: List ty -> List ty
.
deal ['a','b','c','d'] == (['a', 'c'], ['b', 'd'])
top_three : Ord a => List a -> List a
that outputs the
three largest elements of a list. You may find the following
predefined functions useful: take : Nat -> List a -> List a
and
sort : Ord a => List a -> List a
. Check out the documentation
(:doc
) for the details.
top_three [2,1,4,3,0] == [4,3,2]
myUnzip: List (ty, ty') -> (List ty, List ty')
that unzips a zipped list.
myUnzip [(2,'a'),(5,'b')] == ([2, 5], ['a', 'b'])
Address
record definition from the lectures. Type
it out (and mind the typo, country
should be type String
not
string
.) Check the type of record {city = "Tallinn"}
or record
{city = "Tallinn", postcode=10138}
. Define a new record type called
Street
that has fields number: Int
and street : String
. Write
functions getStreet: Address -> Street
and setStreet: Street ->
Address -> Address
.