fun f(a: Array<String>, collect:String = "") =
    if(isEmpty(a))
        collect
    else if(a[0] == "Clear")
        f(a[1 to -1])
    else
        f(a[1 to -1],  collect ++ a[0])
---
f(["Read", "Clear", "Read" , "Foo"])