-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
59 lines (50 loc) · 796 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Atividade 2
// Extensão Quokka usada no VSCode
let x
// Currying
// λa.a
// JS I(I) === I
const I = a => a
x = I(1)
x
// λab.a
// JS K = a => b => a
const K = a => b => a
x = K(1)(2)
x
// λab.b
// JS KI = a => b => b
const KI = a => b => b
x = KI(1)(2)
x
// λfab.fba
// JS C = f => a => b => f(b)(a)
const C = f => a => b => f(b)(a)
x = C(K)(1)(2)
x
x = C(KI)(1)(2)
x
// Boolean
// TRUE ? PRI : ULT
// FALSE ? PRI : ULT
const T = K
const F = KI
T.inspect = () => "True (K)"
F.inspect = () => "False (KI)"
T
F
// λp.pFT
// JS NOT = a => a(F)(T)
const NOT = a => a(F)(T)
r = NOT(F)
r
// λab.abF ou λab.aba
// JS AND = a => b => a(b)(F)
const AND = a => b => a(b)(F)
x = AND(T)(F)
x
// λab.aTb ou λab.aab
// JS OR = a => b => a(T)(b)
const OR = a => b => a(T)(b)
x = OR(T)(F)
x