# Talk:Blow your mind

### From HaskellWiki

m |
Eightyeight (Talk | contribs) m |
||

(6 intermediate revisions by 3 users not shown) | |||

Line 1: | Line 1: | ||

− | |||

==Name?== | ==Name?== | ||

Line 5: | Line 4: | ||

i completely agree, the name pretty much sucks. but what i really wanted, was to compile a collection of "idioms" that would enlarge the readers perception of what is possible in Haskell and how to go about it. so, i'll have to find a name that reflects this plan. —--[[User:JohannesAhlmann|J. Ahlmann]] 14:13, 2 March 2006 (UTC) | i completely agree, the name pretty much sucks. but what i really wanted, was to compile a collection of "idioms" that would enlarge the readers perception of what is possible in Haskell and how to go about it. so, i'll have to find a name that reflects this plan. —--[[User:JohannesAhlmann|J. Ahlmann]] 14:13, 2 March 2006 (UTC) | ||

+ | |||

+ | == List / String Operations == | ||

+ | |||

+ | Should this: | ||

+ | |||

+ | transpose . unfoldr (\a -> toMaybe (null a) (splitAt 2 a)) | ||

+ | |||

+ | be this instead: | ||

+ | |||

+ | transpose . unfoldr (\a -> toMaybe (not $ null a) (splitAt 2 a)) | ||

+ | |||

+ | == Polynomial signum and abs == | ||

+ | |||

+ | A sensible option for signum and abs for polynomials (with coefficients from a field) would be | ||

+ | |||

+ | * signum -> the leading coefficient | ||

+ | * abs -> the monic polynomial obtained by dividing by the leading coefficient | ||

+ | |||

+ | As with the abs and signum functions for Integer and for Data.Complex (when restricted to a subring whose intersection with the real numbers is just the integers), the result of this signum is then a unit (ie, a value x for which there exists a y such that xy = 1), and we have | ||

+ | |||

+ | * signum a * abs a = a | ||

+ | * abs 1 = signum 1 = 1 | ||

+ | * abs (any unit) = 1 | ||

+ | * abs a * abs b = abs (a * b) | ||

+ | |||

+ | == Polynomial negate == | ||

+ | |||

+ | Why not: | ||

+ | |||

+ | <haskell>negate = map negate</haskell> |

## Latest revision as of 12:55, 29 May 2013

## Contents |

## [edit] 1 Name?

Is there a better name for this page? —Ashley Y 00:55, 2 March 2006 (UTC)

i completely agree, the name pretty much sucks. but what i really wanted, was to compile a collection of "idioms" that would enlarge the readers perception of what is possible in Haskell and how to go about it. so, i'll have to find a name that reflects this plan. —--J. Ahlmann 14:13, 2 March 2006 (UTC)

## [edit] 2 List / String Operations

Should this:

transpose . unfoldr (\a -> toMaybe (null a) (splitAt 2 a))

be this instead:

transpose . unfoldr (\a -> toMaybe (not $ null a) (splitAt 2 a))

## [edit] 3 Polynomial signum and abs

A sensible option for signum and abs for polynomials (with coefficients from a field) would be

- signum -> the leading coefficient
- abs -> the monic polynomial obtained by dividing by the leading coefficient

As with the abs and signum functions for Integer and for Data.Complex (when restricted to a subring whose intersection with the real numbers is just the integers), the result of this signum is then a unit (ie, a value x for which there exists a y such that xy = 1), and we have

- signum a * abs a = a
- abs 1 = signum 1 = 1
- abs (any unit) = 1
- abs a * abs b = abs (a * b)

## [edit] 4 Polynomial negate

Why not:

negate = map negate