reduce as a lambda