Re: [Haskell-cafe] Does somebody know about these functions?

2012-03-03 Thread wren ng thornton
On 2/29/12 11:42 PM, Tony Morris wrote: On 01/03/12 14:40, wren ng thornton wrote: Of course, you can simplify the implementation by: inter f xs = zipWith f xs (tail xs) inter f = zipWith f * tail Whee, golf! :) -- Live well, ~wren ___

Re: [Haskell-cafe] Does somebody know about these functions?

2012-03-01 Thread Johan Holmquist
So, these two functions do not appear to be defined, perhaps because many of their potential uses could be expressed using the functions from Data.Applicative and Data.Arrow instead. You may have noticed that the words and lines examples where defunct, but not difficult to fix: words = go .

Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-29 Thread wren ng thornton
On 2/28/12 1:25 PM, Brent Yorgey wrote: On Tue, Feb 28, 2012 at 06:06:25PM +0100, Johan Holmquist wrote: inter :: (a - a - b) - [a] - [b] inter f [] = [] inter f l = map (uncurry f) $ zip l (tail l) I've never seen this function defined anywhere, but it looks nice. I've used it a few

Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-29 Thread Tony Morris
On 01/03/12 14:40, wren ng thornton wrote: Of course, you can simplify the implementation by: inter f xs = zipWith f xs (tail xs) inter f = zipWith f * tail -- Tony Morris http://tmorris.net/ ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-28 Thread Brent Yorgey
On Tue, Feb 28, 2012 at 06:06:25PM +0100, Johan Holmquist wrote: inter :: (a - a - b) - [a] - [b] inter f [] = [] inter f l  = map (uncurry f) $ zip l (tail l) I've never seen this function defined anywhere, but it looks nice. withPair :: (a' - b' - c) - (a - a') - (b - b') - (a,b) - c

Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-28 Thread Holger Siegel
Am 28.02.2012 um 18:06 schrieb Johan Holmquist: Two functions that I see useful are described here and I would like to know if they are defined in some more or less standard Haskell library. Hoogle (http://www.haskell.org/hoogle) did not reveal anything about that. Function 'inter'

Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-28 Thread Johan Holmquist
inter :: (a - a - b) - [a] - [b] inter f [] = [] inter f l = map (uncurry f) $ zip l (tail l) This is the same as inter :: (a - a - b) - [a] - [b] inter f l = zipWith f l (tail l) Except when l == [], but the second equation can be replaced by this nicer one. and you can use it to

Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-28 Thread Holger Siegel
Am 28.02.2012 um 20:21 schrieb Johan Holmquist: inter :: (a - a - b) - [a] - [b] inter f [] = [] inter f l = map (uncurry f) $ zip l (tail l) This is the same as inter :: (a - a - b) - [a] - [b] inter f l = zipWith f l (tail l) Except when l == [], but the second equation can be

Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-28 Thread Johan Holmquist
Except when l == [], but the second equation can be replaced by this nicer one. Even then. :) (zipWith f l (tail l)) first tries to match l with pattern (a:as), and if that fails it will not touch its other argument (tail l). Hm, you're right, it did work for empty lists. I wonder if one

Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-28 Thread Stephen Tetley
On 28 February 2012 17:06, Johan Holmquist holmi...@gmail.com wrote: Function 'withPair' takes a pair and applies a function to it's first element, another function to it's second element and finally combines the results with yet another function. withPair :: (a' - b' - c) - (a - a') - (b -