fold samples added in scala