melody as a function