Alternative If statements
I don't like to use other peoples work, so I make my own "if" statements.
0
2 replies to this topic
#1
Posted 16 October 2018 - 06:00 PM
#2
Posted 13 January 2019 - 11:58 AM
But this uses the or, not and and operators! You need a new version which is free of stuff other people made.
#3
Posted 13 January 2019 - 01:17 PM
osmarks, on 13 January 2019 - 11:58 AM, said:
But this uses the or, not and and operators! You need a new version which is free of stuff other people made.
local _true = function(x, _) return x end local _false = function(_, y) return y end local function _if(cond, t, f) return cond(t, f) end local function _not(x) return x(_false, _true) end local function _and(x, y) return x(y, _false) end local function _or(x, y) return x(_true, y) end local hungry = _true local potato = _true print(_if(hungry, "Grab potato", "Should I eat")) _if(_and(hungry, potato), function() print("That's true!") end, function() print("That's false!") end )()There we go, reimplemented using Church Booleans. Truly the future is upon us.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users