Quiz Stuff

Quiz 5; February 8; Three minutes; 1+2 points

  1. Write your own implementation of the Prelude's length function.
  2. Write a function ftups that "flattens" a list of two-tuples into a list of individual values. Example:
    > ftups [(1,2),(3,4),(5,6)]
    [1,2,3,4,5,6]
    
    > ftups [('t','e'),('s','t'),('e','d')]
    "tested"
    
EC ½ point: What's the type of ftups?

Solutions

length [] = 0
length (_:t) = 1 + length t

ftups [] = []
ftups ((x,y):ts) = x:y:ftups ts