Vortex-wake interactions of a flapping foil that models animal swimming and flight