(head . map f) xs = (f . head) xs
It works for every xs list when f is strict. Can anyone give me example, why with non-strict f it doesnt work?
Let's take the non-strict function f = const ()
, and xs = undefined
. In this case, we have
map f undefined = undefined
but
f undefined = ()
and so
(head . map f) undefined = head (map f undefined) = head undefined = undefined
but
(f . head) undefined = f (head undefined) = f undefined = ()
QED
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.