exercise 5.5 takeWhileViaFoldRight implemented