count datafiles that satisfy a passed in function