gpt4 book ai didi

haskell - Haskell中如何避免重复的函数调用

转载 作者:行者123 更新时间:2023-12-02 17:05:17 24 4
gpt4 key购买 nike

如何避免此 Haskell 命令中重复的 x

ccheck :: Balance -> Integer
ccheck b | x >= 1200 = x - 7
| otherwise = x
where x = account b

最佳答案

好吧,你几乎可以让任何东西都变得免费。

import Control.Arrow
ccheck = uncurry (+) . (min 0 . (*7) . signum . (1199-) &&& id) . account

但是WTH。你的版本很好,更清楚发生了什么,而且正如三十二上校所说,根本没有那么重复。

关于haskell - Haskell中如何避免重复的函数调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27025259/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com