In a large bowl, toss the sweet potatoes generously with some olive oil, salt, cinnamon and cayenne. Lay the sweet potatoes out on a sheet tray, place them in the oven and roast until they are very soft and mushy, 30 to 35 minutes.
Peel the apples and cut into 1-inch dice. Toss the apples with the lemon juice, some olive oil, salt and the rosemary. Lay them out on a sheet tray and place in the oven during the last 15 minutes of the cooking time for the sweet potatoes. When done, the apples should be soft and cooked through but still hold their shape. Sprinkle the walnuts over the apples during the last 5 minutes in the oven.
Transfer the sweet potatoes to a large bowl and coarsely mash them with a potato masher. Stir in the cooked apples and walnuts. Taste and adjust the seasoning if needed.
Serve immediately or keep in a warm oven and serve hot.