Define a function compress : lists(T) → lists(T) that accepts a list argument (of some generic type T) and returns a list without any subsequent redundancies, e.g.
compress(⟨a, a, b, b, b, c, c, a, b⟩) = ⟨a, b, c, a, b⟩

-> Transform the definition into a computable function.
(NO NEED TO CODE, ONLY TRANSFORM INTO COMPUTABLE FUNCTION. For ex:- Construct function reverse(Λ) that reverses a list Λ and unfold the definition for reverse(⟨a, b⟩).
Solution:
reverse (Λ) is
if (Λ = ⟨⟩) then
return ⟨⟩
else
return concat ( reverse ( tail (Λ) , list ( head (Λ))
)

Q&A Education