Trying to reproduce lisp recursion