To my 

>> Is not                   deleteBy :: (a->Bool) -> [a] -> [a]
>> more natural for the library than
>>                          deleteBy :: (a->a->Bool) -> a -> [a] -> [a]
>> ?
>> For example, to remove the first negative from a list, people 
>> suggest usually            deleteBy (< 0) [1,2,-1,3]
>> While                      deleteBy (>) 0 [1,2,-1,3]  
>> needs thinking effort.


Mariano Suarez Alvarez <[EMAIL PROTECTED]>          and 
Hannah Schroeter       <[EMAIL PROTECTED]>

A> isn't the first deleteBy simply filter?

S> That's just filter, with a reversed predicate.
   [..]

No. A filter runs through all the list, and  deleteBy  stops after
the first needed element is found. 


Marcin Qrczak Kowalczyk  <[EMAIL PROTECTED]>  writes

K> Possibly, but then IMHO it should not be called deleteBy, which
K> is a variant of delete with comparison given explicitly instead
K> of through the Eq class.

Maybe.  
I propose for  Haskell-2  to add to the library

  delBy :: (a -> Bool) -> [a] -> [a]
  delBy _ []     = []
  delBy p (a:as) = if  p a  then  as  else  a:(delBy p as) 

------------------
Sergey Mechveliani
[EMAIL PROTECTED]





Reply via email to