-7
\$\begingroup\$

People, it's a popularity contest, you have to do somthing cool here.
Think about cool ways of breaking the code in most languages, not about validating for everyting!

Initially this challenge is NOT for esoteric languages. But I didn't disabled them as I expect voters to be fair enough to downvote answers based only on esoteric language syntax uniqueness.

It's not too broad. I thought about code golf tag, but desided that it will be unnessesary limitation for the answers. I expect anwsers to be short and exploiting some language feature.

By the way, I have an interesting solution for VB.NET and it is shorter than 8 chars :)


Write a statement that multiplies the (integer) variable by 10 and assigns result to the same variable. If your language has no integer type, you may assume that the value is an integer not greater then some limit (you can specify this limit yourself, but it defenitly have to be adequate).

The initial and resulting values have to be number. Using string as one of them (or both) is forbidden.

But you don't want the code to be protable, so you are going to write it in such way, that the code is valid for as few programming languages as possible. Ideally in the only language.

Example:

You have variable

int x = 77;

and the answer is

x *= 10;

Declaration is not the part of the answer, only x *= 10; is.
So this code is valid for C, C++, C#, Java, Javascript and probably some other languages.
It's defenity a bad answer in this challenge.
Just drop a semicolon to cut off C, C++, C# and Java, but VB.NET appears in this case.

Scoring system: it's a popularity contest. For now I'll define the answer score as number of votes, but I'll keep a right to change scoring system by including number of languages into it.

So you have to provide a statement and list of languages (ideally one language) it is valid in.

\$\endgroup\$
  • \$\begingroup\$ And some people just want to watch the world burn. I'd try to come up with a less subjective marking system, though. \$\endgroup\$ – Lui Jan 13 '16 at 10:01
  • 1
    \$\begingroup\$ I don't think it's possible to find all languages a program is valid in. \$\endgroup\$ – PurkkaKoodari Jan 13 '16 at 10:02
  • \$\begingroup\$ @Lui, it's popularity-contest ;) If you are ready to provide better scoring system, I'm ready to consider your proposal. \$\endgroup\$ – Qwertiy Jan 13 '16 at 10:03
  • 4
    \$\begingroup\$ I'm downvoting because this essentially requires an answer to search through every programming language ever to see whether/how many others have the same behavior. Here's a partial list, for reference. \$\endgroup\$ – isaacg Jan 13 '16 at 10:03
  • 2
    \$\begingroup\$ The anti-polyglot idea may work as cops and robbers (polyglots are cracked), but there still is the problem that some languages (esoteric or not) will have a very easy time here. I expect voters to be fair enough to downvote answers based only on esoteric language syntax uniqueness. I don't understand that reasoning at all. The whole point of this challenge is exploiting syntax uniqueness. \$\endgroup\$ – Dennis Jan 13 '16 at 15:16
1
\$\begingroup\$

In Perl you can do:

$var .= 0; 

because it is not typed.

or

$var =~ s/$/0/;

Regex that adds a zero at the end of line.

\$\endgroup\$
  • \$\begingroup\$ Does this code assigns a number to the variable? I trust that you can concatenate numbers, but what the result is? I expect it to be a string, then it's not ok. In this case you need some code to convert it back to number. \$\endgroup\$ – Qwertiy Jan 13 '16 at 10:47
  • \$\begingroup\$ There are no type in Perl, integer and string are stored in same variables. The result for each is 770 \$\endgroup\$ – Toto Jan 13 '16 at 11:02
0
\$\begingroup\$

Vitsy, 2 bytes

a*

Call this method through any normal means (00k or 0m). The top item of the stack will be multiplied by 10 (a in hexadecimal). This is very anti-polyglot because most stack based languages don't have methodology.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.