integrating discrete functions