-
-
Save BytesAndCoffee/94db04a99000b730ab92d044648b8607 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch = lambda x: [lambda x: x // 2, lambda x: x * 3 + 1][x % 2](x) | |
print(switch(5)) | |
~~~ | |
16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch = lambda { |x| [lambda { |x| x / 2 }, lambda { |x| x * 3 + 1}][x % 2](x)} | |
puts switch(5) | |
~~~ | |
collatz.rb:1: syntax error, unexpected '(', expecting '}' | |
...ambda { |x| x * 3 + 1}][x % 2](x)} | |
... ^ | |
collatz.rb:3: syntax error, unexpected end-of-input, expecting '}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment