add func
Merge https://github.com/leotywy/ProgrammingAssignment2