Clemens Fruhwirth <[email protected]> writes:

> 2009/8/18 Dusan Kolar <[email protected]>:
>> Hello all,
>>
>>  During a small project I'm trying to develop a small application. It
>> becomes quite often that I need a function mapapp:
>>
>> mapapp _ [] ap = ap
>> mapapp f (a:as) ap = f a : map f as ap
>>
>>  I tried hoogle to find such a function with no success. Is there any
>> function/functions built-in "standard" libraries that could easily satisfy
>> the functionality with the same or even better (?) efficiency?
>
> Can't think of something like that either but at least we can make it
> shorter and less readable ;)
>
> mapapp f xs tail = foldr ((:) . f) tail xs
>
>>  Of course,
>> (map f list) ++ append
>>  would do the same as
>>
>> mapapp f list append
>>
>>  but with less efficiency. Or am I wrong?
>
> Yes, that is less efficient because ++ has to create N new cons cells
> if "list" has length N.
No, it does not *have to*. 


 
> Fruhwirth Clemens http://clemens.endorphin.org
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>

-- 

                                        S. Y. A(R). A.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to