Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
(head . map f) xs = (f . head) xs
当 f 严格时,它适用于每个 xs 列表。谁能给我举个例子,为什么使用非严格的 f 它不起作用?
让我们采用非严格函数f = const (), 和xs = undefined。在这种情况下,我们有
f = const ()
xs = undefined
map f undefined = undefined
但
f undefined = ()
所以
(head . map f) undefined = head (map f undefined) = head undefined = undefined
(f . head) undefined = f (head undefined) = f undefined = ()
量子点