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
___
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 .
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
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
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
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'
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
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
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
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 -
10 matches
Mail list logo