How to make a function store data to avoid repeating computation

Either one struct that you’re passing to all the various functions or depending on if you’re using maybe multiple threads you might use a channel to send information