同时过滤和映射

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了同时过滤和映射相关的知识,希望对你有一定的参考价值。

The `filtermap` functional below allows to perform the standard `map` and `filter` operations in one go. The mapping function has to return a `Maybe` monad, and values of `Nothing` are filtered out.
  1. -- Prepend an element to a list if available. Leave the list as it is if the
  2. -- first argument is Nothing.
  3. maybecons :: Maybe t -> [t] -> [t]
  4. maybecons Nothing l = l
  5. maybecons (Just e) l = e : l
  6.  
  7. -- Variant of map which deletes elements if the map function returns Nothing.
  8. filtermap :: (a -> Maybe b) -> [a] -> [b]
  9. filtermap _ [] = []
  10. filtermap f (a:as) = maybecons (f a) $ filtermap f as

以上是关于同时过滤和映射的主要内容,如果未能解决你的问题,请参考以下文章

Huawei_Netconf_Ncclient

使用异步过滤和映射 Promise

使用 Spring Security 在同一个 URI 映射上同时支持 Basic 和 Digest 身份验证

为什么我不能在此片段中生成唯一对象数组?

EF添加关联的提示问题:映射从第 260 行开始的片段时有问题:

Python代码阅读(第26篇):将列表映射成字典