小编Vin*_*hou的帖子

如何将函数应用于Haskell中列表中的每个元素?

我想将resolve_on应用于列表c1中的每个元素,比如

for(Char c:c1){
resolve_on c c1 c2;}
Run Code Online (Sandbox Code Playgroud)

那么我怎样才能使用map函数呢?

resolvents :: [Char] -> [Char] -> [[Char]]
resolvents c1 c2 =  map (//what should I do) c1

resolve_on :: Char -> [Char] -> [Char] -> [Char]
resolve_on c c1 c2
Run Code Online (Sandbox Code Playgroud)

lambda haskell map-function

0
推荐指数
1
解决办法
594
查看次数

有没有办法简化这种情况,除了使用循环?

        if(robots[0] != null && !robots[0].isStrong()) {
            if(robots[1] != null &&!robots[1].isStrong()) {
                if(robots[2] != null &&!robots[2].isStrong()) {
                        //do something
                }
            }
        }
Run Code Online (Sandbox Code Playgroud)

我想检查一下所有的机器人是否都不坚固,如果它们都不坚固,那么就做点什么吧.想象一下,我有10个机器人,如果有条件我是否必须写10个?

java

-3
推荐指数
1
解决办法
133
查看次数

标签 统计

haskell ×1

java ×1

lambda ×1

map-function ×1