4 ms·
You're right that it's closer to how people are taught, but there's no reason we can't teach from the FP perspective. Consider the imperative cup_of_water g
by hood_syntax 10y ago
You're right that it's closer to how people are taught, but there's no reason we can't teach from the FP perspective.
Consider the imperative
cup_of_water get_water (cup_loc, water_loc) {
cup = get_cup(cup_loc);
return fill_cup(cup, water_loc);
}
or something like that, versus
getWater :: CupLoc -> WaterLoc -> Cup Water
getWater cupLoc waterLoc = fillCup (getCup cupLoc) waterLoc
It's just a slightly different way of thinking about things.
- hyperpape 10y agoThere's nothing in either example that is intrinsically functional or imperative, they're just different syntax.
- taeric 10y agoThis is dodging things by all being symbolic. Which is well after the point my kids are at in these examples. I'm taking about my one year old. It is amazing how they can understand well before they can say words. Or read and write them. Sign language can be taught really early. Not sure what data that adds here. But, I believe that imperative makes sense because so much in life is imperative. Especially directions we give each other. For things that can be done symbolically, declarative can be a big boon. But it does seem to be the minority.
- pjc50 10y agoNow audit each cup-filling in a database. (Easy in an imperative system, painful in a functional one where you have to start passing monads around and caring how many times the cup is constructed rather than how many cups you end up with.)