Hyperpolyglot: PHP, Perl, Python, Ruby
hyperpolyglot.org
Hyperpolyglot: PHP, Perl, Python, Ruby
1–10 of 58 posts
Re: Hyperpolyglot: PHP, Perl, Python, Ruby
#2Re: Hyperpolyglot: PHP, Perl, Python, Ruby
#3Re: Hyperpolyglot: PHP, Perl, Python, Ruby
#4> Python: Statement separator: ; or sometimes newline
More like newline or sometimes ;. When was the last time you saw a Python script with a semicolon?
> Python: Multiline comment: '''comment line\nanother line'''
That's a multiline string.
Re: Hyperpolyglot: PHP, Perl, Python, Ruby
#5Re: Hyperpolyglot: PHP, Perl, Python, Ruby
#6Re: Hyperpolyglot: PHP, Perl, Python, Ruby
#7Re: Hyperpolyglot: PHP, Perl, Python, Ruby
#8x.succ is not the Ruby equivalent of ++$x in PHP (or Perl). x.succ returns x + 1 (by default, on integers) but does not increment x as ++$x does (since numbers are immutable and that's what "x" is giving us in Ruby). The closest match would be x += 1 (shorthand for x = x + 1). I don't see x = x.succ in common usage but that would work too.
Re: Hyperpolyglot: PHP, Perl, Python, Ruby
#9x.succ is not the Ruby equivalent of ++$x in PHP (or Perl). x.succ returns x + 1 (by default, on integers) but does not increment x as ++$x does (since numbers are immutable and that's what "x" is giving us in Ruby). The closest match would be x += 1 (shorthand for x = x + 1). I don't see x = x.succ in common usage but that would work too.
I don't disagree with what you're saying, but it does mention in the comment that x is not mutated.
I still don't see why it doesn't just use the common syntax though that does the same thing. It's intriguing that the Python one has no example for that row. Perhaps they are specifically looking for idiomatic techniques, even if they're not commonly used.
I note that the page is on a wiki so I could fix it, but given it's been there for years, I suspect there's a good reason no-one has already made the change.
Re: Hyperpolyglot: PHP, Perl, Python, Ruby
#10Over on the ISWIM-family page the Haskell "command line args" program is ten lines long, when it could be:
import System
main = getArgs >>= mapM_ putStrLn
I wish these were written by people who knew the languages.