Is this an ideal use for passing functions as an arguement...

Printable View