> :t (+1)
(+1) :: Num a => a -> a
> :t (-1)
(-1) :: Num a => a
第二个功能如何? 我是否必须写到<条码>(+(-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。 我发现可以读懂的:-
<代码>(-1)代码>为负数,正如其他人所指出的。 缩略语1功能为<代码>x->x-1,flip (-) 1
,或实际上(+(-1))
。
www.un.org/Depts/DGACM/index_french.htm <代码>(-) 1为“从一开始”或<代码>。 -> 1-x)。
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 ...
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....
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: ...
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)...
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 ...
The type of the Prelude function flip is: flip :: (a -> b -> c) -> b -> a -> c I.e., it takes one binary function and two arguments. The type of the Prelude function id is: id :: a -...
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 ...
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?