ex5.2 - improved pattern matching; tried to implement a stack safe version of take(), but need to somehow convert buffered list back to Stream