小编wys*_*iet的帖子

如何使用来自getLine的字符串映射?[Haskell]

我想读取一个String和toUpper所有的字符.

import Data.Char

main = do 
    a <- getLine
    b <- getLine
    map toUpper a
    if (a == b) 
        then print 0
        else if (a < b) 
            then print (-1)
            else print 1
Run Code Online (Sandbox Code Playgroud)

然后我得到了这个

Couldn't match expected type `IO a0' with actual type `[b0]'
    In the return type of a call of `map'
    In a stmt of a 'do' expression: map toUpper a
    In the expression:
      do { a <- getLine;
           b <- getLine;
           map toUpper a;
           if (a == …
Run Code Online (Sandbox Code Playgroud)

haskell map getline

2
推荐指数
2
解决办法
659
查看次数

标签 统计

getline ×1

haskell ×1

map ×1