lambda演算 - 如果需要更多参数

时间:2016-09-06 18:37:12

标签: lambda functional-programming sicp

Lambda微积分问题:

TRUE = lambda x y . x
FALSE = lambda x y . y
1 = lambda s z . s z
2 = lambda s z . s (s z) ...

BoolAnd = lambda x y . x y FALSE
BoolOr = lambda x y. x TRUE y
BoolNot = lambda x . x FALSE TRUE 

If I want to know the result of BoolNot 1:
BoolNot 1
(lambda x . x FALSE TRUE)(lambda s z . s (s z))
(lambda s z . s z) FALSE TRUE
(lambda x y . y) (lambda x y . x)

这里需要x和y 2参数,但这里只有1个, 我怎样才能继续这个微积分?

2 个答案:

答案 0 :(得分:1)

public class NotificationService extends Service { @Nullable @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { super.onCreate(); } @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); Notification no = new Notification.Builder(this.getApplicationContext()) .setSmallIcon(android.R.drawable.sym_action_email) .setContentTitle("Mail from Sathya Tech") .setContentText("For more details , Call Us on 040-65538958, 65538968, 65538978 or email to info@sathyatech.com") .build(); NotificationManager nm = (NotificationManager) this.getApplicationContext().getSystemService(this.getApplicationContext().NOTIFICATION_SERVICE); nm.notify(1, no); /* Notification no1 = new Notification.Builder(context) .setSmallIcon(android.R.drawable.sym_action_chat) .setContentTitle("Ravi") .setContentText("Hello Sir ") .build(); NotificationManager nm1 = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE); nm1.notify(1212, no1);*/ } } 是"简写" λ x y. E

因此,

λx. (λy. E)

即身份功能。

答案 1 :(得分:0)

认为你当时应用了一个参数,并且每个步骤都有一个函数减去一个。执行(not 1)没有意义,但结果是身份函数,因为true成为未使用的变量,因此它将采用另一个参数y并评估为{{1} }