-
-
Save supermomonga/0ef255668bdaeae05f65 to your computer and use it in GitHub Desktop.
PHPとしても実行できるRubyの書きかた ref: http://qiita.com/supermomonga/items/79d599b4ed8b385870b0
This file contains hidden or 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
p <<PHP_VERSION | |
<?php | |
PHP_VERSION | |
;print "\033[1F\033[1M"; |
This file contains hidden or 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
print "\033[1F\033[1M"; |
This file contains hidden or 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
print "\033[1F\033[1M"; |
This file contains hidden or 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
//.tap{ define_method :range, -> s,e { s.upto e } } | |
//.tap{ define_method :array_map, -> f,seq { seq.map{ |x| f.(x) } } } | |
//.tap{ define_method :function, -> x,&b { -> x { $x=x;b.call } } } |
This file contains hidden or 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
//.tap{ ... } |
This file contains hidden or 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
//; ... |
This file contains hidden or 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
array_map(function($x){ | |
print $x % 15 == 0 ? 'FizzBuzz' : ($x % 3 == 0 ? 'Fizz' : ($x % 5 == 0 ? 'Buzz' : $x)); | |
print "\n"; | |
}, range(1,100)); |
This file contains hidden or 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
p <<'PHP_VERSION;' |
This file contains hidden or 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
p <<'PHP_VERSION;' | |
<?php | |
PHP_VERSION; | |
print "\033[1F\033[1M"; |
This file contains hidden or 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
p <<PHP_VERSION | |
<?php | |
PHP_VERSION | |
;print "\033[1F\033[1M"; |
This file contains hidden or 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
p <<PHP_VERSION | |
<?php | |
PHP_VERSION | |
;print "\033[1F\033[1M"; | |
//.tap{ define_method :range, -> s,e { s.upto e } } | |
//.tap{ define_method :array_map, -> f,seq { seq.map{ |x| f.(x) } } } | |
//.tap{ define_method :function, -> x,&b { -> x { $x=x;b.call } } } | |
array_map(function($x){ | |
print $x % 15 == 0 ? 'FizzBuzz' : ($x % 3 == 0 ? 'Fizz' : ($x % 5 == 0 ? 'Buzz' : $x)); | |
print "\n"; | |
}, range(1,100)); |
This file contains hidden or 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
p <<PHP_VERSION | |
<?php | |
PHP_VERSION | |
;print "\033[1F\033[1M"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment