[Haskell-beginners] Definition of last: why complicate it?
ky3 at atamo.com
Sat Apr 5 03:19:03 UTC 2014
On Sat, Apr 5, 2014 at 4:55 AM, Dimitri DeFigueiredo <
defigueiredo at ucdavis.edu> wrote:
> For comparison, could you also translate the inefficient version of plast
> into the case notation you use above?
You probably already know this already, but it's worth underscoring for
everyone that it's not the translation into case notation /per se/ that
gives you the incremental performance improvement.
A function definition by parts is syntactic sugar for a single case
All syntactic sugar, including others like do-notation, where clauses,
etc., gets eliminated at the earliest stages when code is handed off to ghc.
I encourage newcomers to familiarize themselves with desugaring to avoid
unpleasant surprises. The sugared syntax often suggests mystery and magic
when there's really nothing of that sort at all.
Coming back to the topic of function definition by parts, aka piecewise
definition, it appears that at least one reputable school thinks it's
"weird" and "confusing" enough to be warrant a ban in homework:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners