Bend/examples/fusing_not.bend

17 lines
492 B
Plaintext
Raw Permalink Normal View History

# Example of a boolean 'not' function that fuses inifinitely through composition..
2024-01-11 21:32:41 +03:00
true = λt λf t
false = λt λf f
2024-01-11 21:32:41 +03:00
not = λboolean (boolean false true)
fusing_not = λboolean λt λf (boolean f t)
2024-05-15 22:26:16 +03:00
# Creates a Church numeral out of a native number
2024-04-03 21:47:47 +03:00
to_church n = switch n {
0: λf λx x
_: λf λx (f (to_church n-1 f x))
}
2024-01-11 21:32:41 +03:00
main =
# Self-composes `not` 2^23-1 times and prints the result.
((to_church 0x7FFFFF) fusing_not) # try replacing 'fusing_not' by 'not'. Will it still work?