English 中文(简体)
评价“主要=回返(植被、收获)”
原标题:evaluate "main = return (getChar, getChar)"
  • 时间:2012-05-13 00:28:59
  •  标签:
  • haskell

我很抱歉,我说不好。

见下文准则。

main = getChar

首先,将评估主要价值,其价值是“植被”,但汇编者并不了解“植物群”价值,因此汇编者将评价“植物群”以计算“植物群”价值,因此将实施“收获”。

实际上,一经测试上述代码。 执行了“植被”。

见下文准则。

main = return (getChar, getChar)

首先,主要评价是回报(未界定、未界定)-> IO(未界定、未界定),这样预先定义将评价IO(未界定、未界定)印刷价值。 两人中有一人 将对慈善工作进行评价。

但是,在测试上述代码时,没有两部得到任何测试。 没有对慈善机构进行评估。 我不理解为什么没有评估两个收获季节。

问题回答

你必须实际执行 mo行动,然后恢复执行结果。

func = do
    a <- getChar
    b <- getChar
    return  (a,b)

你目前正在做的是C声明:

void main(char &a, char &b)
{
    a = getchar;
    b = getchar;
}

而不是你真的想要:

void main(char &a, char &b)
{
    a = getchar();
    b = getchar();
}

“我想知道,为什么没有评估两个收获季节”。

首先,如逻辑或数学或陶瓷(而不是p))= 页: 1

我想知道,为什么对这两个老虎进行评价。

Conf,因为我没有评价他们。

你的主要职能是计算国际交易日志(IOa)的价值,然后评估国际交易日志内部的类型。 在你的案件中,是(IO Char, IO Char)。 由于Haskell语是非严格语言,评估理论公正意味着构造。 这不包括对教学内容的评价。 例如:

fst (42, 7 `quot` 0 :: Int)

will not abort with division by zero error. Hence we have:

(getChar, getChar) 

is a tuple with 2 unevaluated values. But even if the values are evaluated, we have 2 values of type IO Char. Such a value can be seen as an action that, when executed in the IO monad, returns a Char.

因此,不仅没有评价你的图形成分,而且也没有在IO monad实施。

为了做到这一点,你可以把两项行动推向另一项行动:

executeBoth (a,b) = do
    ra <- a
    rb <- b
    return (ra, rb)

现在,检查执行类型 你们都可以看到这一点。





相关问题
Euler Problem in Haskell -- Can Someone Spot My Error

I m trying my hand at Euler Problem 4 in Haskell. It asks for that largest palindrome formed by multiplying two three-digit numbers. The problem was simple enough, and I thought my Haskell-fu was up ...

How does foldr work?

Can anybody explain how does foldr work? Take these examples: Prelude> foldr (-) 54 [10, 11] 53 Prelude> foldr (x y -> (x+y)/2) 54 [12, 4, 10, 6] 12.0 I am confused about these executions....

Efficient queue in Haskell

How can I efficiently implement a list data structure where I can have 2 views to the head and end of the list, that always point to a head a tail of a list without expensive calls to reverse. i.e: ...

Problem detecting cyclic numbers in Haskell

I am doing problem 61 at project Euler and came up with the following code (to test the case they give): p3 n = n*(n+1) `div` 2 p4 n = n*n p5 n = n*(3*n -1) `div` 2 p6 n = n*(2*n -1) p7 n = n*(5*n -3)...

Ways to get the middle of a list in Haskell?

I ve just started learning about Functional Programming, using Haskel. I m slowly getting through Erik Meijer s lectures on Channel 9 (I ve watched the first 4 so far) and in the 4th video Erik ...

haskell grouping problem

group :: Ord a => [(a, [b])] -> [(a, [b])] I want to look up all pairs that have the same fst, and merge them, by appending all the list of bs together where they have the same a and discarding ...

Closest equivalent to subprocess.communicate in Haskell

I want to do a popen() / python s subprocess.communicate from Haskell - start a program, give it stdin, and get its stdout/stderr. What s the most direct / Haskellish way to do this?

热门标签