Could all this be implemented with `iterate` and `take-while`?