using the y combinator to implement length and depth