English 中文(简体)
2. +1与-1之间的差额
原标题:The difference between +1 and -1
> :t (+1)
(+1) :: Num a => a -> a

> :t (-1)
(-1) :: Num a => a

第二个功能如何? 我是否必须写到<条码>(+(-1)),或者有更好的办法?

最佳回答

这是因为<代码>(-1)被解释为否定代码,但<代码>(+1)被解释为曲线功能<代码>(x->1+x)。

在斜体内,(a **)为:intactic food for (**) a;(**a)。 ->x **a)。 但是,<代码>(-)是一个特殊案例,因为它既是非固定操作者(门槛)又是双轨操作者(采矿者)。 因此,不能在这里明确应用这种合成糖。 如你想要<条码>(x->a-x),可写<条码>(-),如在上已经回答, 限制下限:, 您可使用<条码>和<条码>的功能, 代号: 和<条码> ,在非普通职能与双亲<条码>-<条码>功能之间互不兼容。

问题回答

Do I have to write (+(-1)) or is there a better way?

我刚刚发现了一个名为<代码>的代号的功能,因此我也可以说<代码>后附1。 我发现可以读懂的:-





相关问题
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?

热门标签