To correct some typos. Sorry! > > How about this: > > > > makeChanges total coins = > > tail $ map fst $ scanl (\(how_many,rest) -> divMod rest) (0,total) coins > > You may want to push it further: > > makeChanges total = > tail . map fst . scanl (divMod . snd) (0,total) > > which, IMHO, is a little obfuscated (although some people may think this is > actually easier to understand). If the reader does not know what divMod does, > the code can be mysterious. However in your original code, the expression > > let (how_many,rest) = divMod n coin_val in ... > > is quite self-explanatary. ... self-explanatory. > Higher-orderness, is used unwisely, can be bad. ... if used unwisely, ... -- Zhanyong Wan
- Another question about higher order functions Friedrich Dominicus
- Re: Another question about higher order functions Zhanyong Wan
- Re: Another question about higher order funct... Friedrich Dominicus
- Re: Another question about higher order functions Paul Hudak
- Re: Another question about higher order functions Zhanyong Wan
- Re: Another question about higher order funct... Zhanyong Wan
- Re: Another question about higher order funct... Friedrich Dominicus
- Re: Another question about higher order functions Friedrich Dominicus
- Re: Another question about higher order functions Benjamin L. Russell
- Re: Another question about higher order funct... Friedrich Dominicus
- RE: Another question about higher order functions Simon Peyton-Jones