the function consumes a list of int and produces the unique elements in the list in increasing order. For examples:
singles([4,1,4,17,1]) => [1,4,17]
I only can do it in O(n^2) running time and wonder how to change into O(n) running time without loop.
def singles(lst):
if lst==[]: return []
else:
rest_fn = list (filter (lambda x: x!=lst[0], lst[1:]))
return [lst[0]] + singles(rest_fn)