Oh snap, the simplify looks crazy! It would be so cool if you could make a post explaining how each little piece works in many details, once you are finished.
You are viewing a single comment's thread from:
Oh snap, the simplify looks crazy! It would be so cool if you could make a post explaining how each little piece works in many details, once you are finished.
There are basically three transformations.
sortOn snd polypoly is a list of tuples of two numbers for each polynomial term's coefficient and power. First step sorts the list of tuple by its second element which is power.
groupBy ...We group all terms by their power.
groupByreturns a list of lists. Each list represent a power value.map fFor each list of lists we
foldlthe list which is basically reducing the list to a single value. For instance if we have5x^2-3x^2+x^2it evaluates to3x^2.Once you get used to functional programming, most things will look very clear. ;)
Take a look: http://learnyouahaskell.com
I would agree.
meep
beep loves coding ? :D
meep