有没有更好的方法来表达无点记号的绝对误差函数? [英] Is there a better way to express the absolute error function in point-free notation?

查看:118
本文介绍了有没有更好的方法来表达无点记号的绝对误差函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

absoluteError xy = abs(xy)



一个不含糊的例子:
$ b $ p = curry(abs。uncurry c code

解决方案

以下是您可以自己派生的小步骤:

  absoluteError xy = abs(xy)= abs(( - )xy)= abs((( - )x)y)
= - )x)y =((abs。)(( - )x))y =
=((abs。)。( - ))xy

因此,通过 eta-reduction ,如果 fxy = gxy 我们得出结论 f = g

此外,使用 <$ c
$ b

 (绝对值)。 )。 ( - )= _B(绝对)( - )= _B(_B abs)( - )=(_B。_B)abs( - )
=((。)。(。))abs( - )


In pointful notation:

absoluteError x y = abs (x-y)

An unclear example in pointfree notation:

absoluteError' = curry (abs . uncurry (-))

解决方案

Here's how you could derive it yourself, in small steps:

absoluteError x y = abs (x-y) = abs ((-) x y) = abs ( ((-) x) y) 
                  = (abs . (-) x) y = ( (abs .) ((-) x) ) y = 
                  = ( (abs .) . (-) ) x y

so, by eta-reduction, if f x y = g x y we conclude f = g.

Further, using _B = (.) for a moment,

(abs .) . (-) = _B (abs .) (-) = _B (_B abs) (-) = (_B . _B) abs (-)
              = ((.) . (.)) abs (-)

这篇关于有没有更好的方法来表达无点记号的绝对误差函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆