每次我对函数进行递归时,我都想刷新一个变量值。为了简单起见,我会给你一个例子。
假设我们给一个函数一个数字 (n),它将返回它可以拥有的最大的 mod,其数字小于自身。
{- Examples:
n=5 `mod` 5
n=5 `mod` 4
n=5 `mod` 3
n=5 `mod` 2
n=5 `mod` 1
-}
example :: Integer -> Integer
example n
| n `mod` ... > !The biggest `mod` it found so far! && ... > 0
= !Then the biggest `mod` so far will change its value.
| ... = 0 !The number we divide goes 0 then end! = 0
其中... =递归(我认为)
我不知道如何更好地描述它。如果你能帮助我,那就太好了。:)