Re: [Haskell-cafe] A functional programming solution for Mr and Mrs Hollingberry
On Wed, May 23, 2012 at 11:37 PM, Richard O'Keefe wrote: > > On 21/05/2012, at 5:33 AM, Andreas Pauley wrote: >> With this in mind I've created a programming exercise where I imagine >> an OO programmer would use an object hierarchy with subtype >> polymorphism as part of the solution. > > Being unfamiliar with git, I've submitted an AWK answer by e-mail. I have committed the awk version for those interested to see: https://github.com/apauley/HollingBerries/tree/master/awk/RichardOKeefe > > I've used quite a few OO languages. I like to think that I *am* > an OO programmer. But this exercise struck me from the beginning > as something where classes would add nothing but bulk. As a fan > of Smalltalk, I have to say that the Smalltalk version confirmed > this for me; a Smalltalk solution for this exercise could be a lot > smaller than that one if it _didn't_ introduce new classes. Maybe this is an example of where we as an industry has been somewhat brainwashed. For many programmers it is difficult to envision coding pretty much anything without classes. Do you know of an exercise where classes would add value? Something fairly small, roughly similar in size to this exercise. -- http://pauley.org.za/ http://twitter.com/apauley ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A functional programming solution for Mr and Mrs Hollingberry
On Mon, May 21, 2012 at 12:54 AM, Artyom Kazak wrote: > Andreas Pauley писал(а) в своём письме Sun, 20 May 2012 > 20:33:13 +0300: > > >> I want to see how elegant a solution I can get in a functional >> language, given that the problem description is not really elegant at >> all. It has a few annoying exceptions to the normal rules, typical of >> what one might get in a real specification from some client. > > > After taking a look at other solutions, I feel like I will have to explain > myself, so I’d better do that without prompting :) > > - nothing was said about meaningful error messages, so I didn’t bother. > - I had decided against defining constants like > `supplier_markup_percentage_modification` > separately; `PremiumSupplierIDs` and markup table are defined locally in > the `calc` > function, too. The latter two issues are fixed in the next version, as > someone > may consider them to be against elegance. > - surprisingly, all solutions use explicit comparisons to determine the > product > category. While it is okay for continuous ranges of codes, it doesn’t > scale and > not really elegant. Fixed as well. Thanks, I've merged this. Had a quick look at the code, I like it :-) -- http://pauley.org.za/ http://twitter.com/apauley ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] A functional programming solution for Mr and Mrs Hollingberry
Hi all, I'm in the process of learning how to approach problems from a functional perspective, coming from an Object Oriented background (mostly Smalltalk). One of the general concerns/questions raised when talking to people in a similar position is: "How do I design/model a problem when I don't have my trusted classes and objects available?" With this in mind I've created a programming exercise where I imagine an OO programmer would use an object hierarchy with subtype polymorphism as part of the solution. And then I'd like to compare functional implementations of the same problem: https://github.com/apauley/HollingBerries I want to see how elegant a solution I can get in a functional language, given that the problem description is not really elegant at all. It has a few annoying exceptions to the normal rules, typical of what one might get in a real specification from some client. Currently there are 3 implementations: - one in Erlang, my attempt at implementing a functional solution - one in Ruby, my attempt to see how an object hierarchy could be used - one in Clojure, done by one of the people in our FP user group [1] I would love to include some Haskell implementations as well, if any of you are interested. Kind regards, Andreas Pauley 1. http://www.meetup.com/lambda-luminaries/ -- http://pauley.org.za/ http://twitter.com/apauley ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe