Sleep was mentioned as being important for learning, as it erases some memories and makes the more important parts easier to remember. The brain rehearses the neural patterns of what you are trying to learn. It helps you figure out difficult problems and understand your topic.
"It's as if the complete deactivation of the conscious you in the pre-frontal cortex at the forefront of your brain helps other areas of your brain start talking more easily to one another, allowing them to put together the neural solution to your learning task while you're sleeping."
It was also mentioned that napping can help creativity, with Dali and Einstein mentioned having an interesting napping technique where they would sleep in a chair while holding something. Dropping the object would cause them to wake up with allegedly boosted creative ideas on the problem they had in mind.
Here's Henri Poincaré on how how he discovered Fuchsian functions:
For fifteen days I strove to prove that there could not be any functions like those I have since called Fuchsian functions. I was then very ignorant; every day I seated myself at my work table, stayed an hour or two, tried a great number of combinations and reached no results. One evening, contrary to my custom, I drank black coffee and could not sleep. Ideas rose in crowds; I felt them collide until pairs interlocked, so to speak, making a stable combination. By the next morning I had established the existence of a class of Fuchsian functions, those which come from the hypergeometric series; I had only to write out the results, which took but a few hours.
It argues that you should sleep if you are going to do some analytical and logical thinking, and not sleep if you are going to come up with creative ideas. But some come up with creative ideas after sleeping (it was Elon Musk who said he came up with the best ideas in the shower after sleeping), so the area is confusing.