implement head using foldr1