We’ve done that to great effect several times.
As we’re brewing we rack the previous batch into a secondary, or the keg.
Then when we’re done chilling the brew in progress, you can go two ways. Either remove a bunch of the cake and pitch the new beer into the same fermenter. (Wife thinks this is gross, esp with the crusty krausen ring) OR (wife’s preferred approach) put the new wort into a clean fermenter and scoop some old cake into it. We’ve seen many ferments take off with ZERO lag this way. So be sure your temps are controlled from the start.
It’s also a great way to avoid yeast starters. We’ve done a 3-gallon patersbier with the intent of using that cake in a trippel. 8-10 gallons of beer from one smack-pack, no wasted DME on the starter... everyone is happy! (Except maybe Wyeast...)