Eric Kow <[email protected]> writes:

> Haddockize add_to_list.
> -----------------------
>> +-- | Add a new element to a list, as long as that element is not
>> +-- already in the list.
>>  add_to_list :: Eq a => a -> [a] -> [a]
>>  add_to_list s [] = [s]
>> hunk ./src/Darcs/Repository/Prefs.lhs 384
>> -add_to_list s (s':ss) = if s == s' then (s:ss) else s': add_to_list s ss
>> +add_to_list s (s':ss) | s == s'   = s:ss
>> +                      | otherwise = s': add_to_list s ss
>
> False advertising, and also the kind of refactor I would have just
> avoided (churn without appreciable gain in clarity, i.e. one could have
> argued that the previous version (sans excess parens) would have been
> more readable... I don't know which is which, but the fact that it's not
> cut and dry probably means it's wisest to leave it alone)

Can't you add to the front instead?

add_to_list s ss | s `elem` ss = ss
                 | otherwise   = s:ss
-- 
Feri.
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to