Skip to content

Instantly share code, notes, and snippets.

@supermomonga
Last active October 17, 2017 09:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supermomonga/0ef255668bdaeae05f65 to your computer and use it in GitHub Desktop.
Save supermomonga/0ef255668bdaeae05f65 to your computer and use it in GitHub Desktop.
PHPとしても実行できるRubyの書きかた ref: http://qiita.com/supermomonga/items/79d599b4ed8b385870b0
p <<PHP_VERSION
<?php
PHP_VERSION
;print "\033[1F\033[1M";
print "\033[1F\033[1M";
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 } } }
//.tap{ ... }
array_map(function($x){
print $x % 15 == 0 ? 'FizzBuzz' : ($x % 3 == 0 ? 'Fizz' : ($x % 5 == 0 ? 'Buzz' : $x));
print "\n";
}, range(1,100));
p <<'PHP_VERSION;'
p <<'PHP_VERSION;'
<?php
PHP_VERSION;
print "\033[1F\033[1M";
p <<PHP_VERSION
<?php
PHP_VERSION
;print "\033[1F\033[1M";
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));
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