Skip to content

Instantly share code, notes, and snippets.

@leobessa
Created November 11, 2010 22:13
Show Gist options
  • Save leobessa/673304 to your computer and use it in GitHub Desktop.
Save leobessa/673304 to your computer and use it in GitHub Desktop.
True = lambda { |a,b| a }
False = lambda { |a,b| b }
display = lambda { |boolean| boolean['true','false']}
display[True] # => "true"
display[False] # => "false"
And = lambda{ |b1,b2| b1[b2,b1] }
Or = lambda{ |b1,b2| b1[b1,b2] }
Not = lambda{ |b| b[False,True] }
display[And[True ,True]] # => "true"
display[And[True ,False]] # => "false"
display[And[False,True]] # => "false"
display[And[False,False]] # => "false"
display[Or[True ,True]] # => "true"
display[Or[True ,False]] # => "true"
display[Or[False,True]] # => "true"
display[Or[False,False]] # => "false"
display[Not[True]] # => "false"
display[Not[False]] # => "true"
@peas
Copy link

peas commented Nov 11, 2010

boa!

olha que legal da mais pra fazer. em vez de

if cond
isso
else
aquilo

cond(isso, aquilo)

bacana nao? a la smalltalk.

@lcs-felix
Copy link

Muito interessante!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment