6 posts
                
             
            
                Posted 16 October 2018 - 07:00 PM
                Alternative If statementsI don't like to use other peoples work, so I make my own "if" statements.

 
                
             
         
        
        
            
            
                
                    
                
                23 posts
                
             
            
                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.
                
             
         
        
        
            
            
                
                    
                
                1426 posts
                
                    
                        Location
                        Does anyone put something serious here?
                    
                
             
            
                Posted 13 January 2019 - 01:17 PM
                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.