How can you ensure that when you throw iron nuggets on an anvil, they transform into iron ingots?

Surely with functions we do that but I don't see how since I never understood how to do it unfortunately...
Continue to help post