Names for small functions: just say no... Re: Data.List.join

Henning Thielemann lemming at henning-thielemann.de
Mon Oct 30 02:37:55 EST 2006


On Fri, 27 Oct 2006, Josef Svenningsson wrote:

> My argument for intercalate builds on the fact that intersperse seems
> to be the wrong abstraction. Recall that I supplied some evidence that
> intersperse is only used together with concat:
> http://www.google.com/codesearch?q=file%3A%5C.hs+intersperse&btnG=Search+Code
> 
> Except for pretty printing, intersperse always comes together with
> concat.

I can tell you at least two non-concat applications of 'intersperse'.  

1. Transforming a power series for 'f' to the onw for '\x -> f(x^2)'
is simply 'intersperse 0'.
2. Upsampling a signal as needed for wavelet transform.

However, you can argue that these applications are special cases of
inserting (n-1) zeros between list items in order to multiply the length
by a factor of n, and thus 'intersperse' doesn't scale well for this
purpose.


More information about the Libraries mailing list