GolfScript, 11 chars
{`".~"+=}.~
Without the =, this code would be a quine that generates its own source code as a string. The = makes it compare this string to its input and output 1 if they match and 0 if they don't.
Note that the comparison is exact — in particular, a trailing newline at the end of the input will cause it to fail.
Explanation:
{ }is a code block literal in GolfScript;.duplicates this code block, and~executes the second copy (leaving the first on the stack);`stringifies the code block, and".~"~"++ appends.~to it;- finally,
=compares the resulting string with the input (which is pushed on the stack as a string by the GolfScript interpreter before the program starts) and returns1if they match and0if they don't.
GolfScript, 11 chars
{`".~"+=}.~
Without the =, this code would be a quine that generates its own source code as a string. The = makes it compare this string to its input and output 1 if they match and 0 if they don't.
Note that the comparison is exact — in particular, a trailing newline at the end of the input will cause it to fail.
Explanation:
{ }is a code block literal in GolfScript;.duplicates this code block, and~executes the second copy (leaving the first on the stack);`stringifies the code block, and".~"+ appends.~to it;- finally,
=compares the resulting string with the input (which is pushed on the stack as a string by the GolfScript interpreter before the program starts) and returns1if they match and0if they don't.
GolfScript, 11 chars
{`".~"+=}.~
Without the =, this code would be a quine that generates its own source code as a string. The = makes it compare this string to its input and output 1 if they match and 0 if they don't.
Note that the comparison is exact — in particular, a trailing newline at the end of the input will cause it to fail.
Explanation:
{ }is a code block literal in GolfScript;.duplicates this code block, and~executes the second copy (leaving the first on the stack);`stringifies the code block, and".~"+appends.~to it;- finally,
=compares the resulting string with the input (which is pushed on the stack as a string by the GolfScript interpreter before the program starts) and returns1if they match and0if they don't.
GolfScript, 11 chars
{`".~"+=}.~
Without the =, this code would be a quine that generates its own source code as a string. The = makes it compare this string to its input and output 1 if they match and 0 if they don't.
Note that the comparison is exact — in particular, a trailing newline at the end of the input will cause it to fail.
Explanation:
{ }is a code block literal in GolfScript;.duplicates this code block, and~executes the second copy (leaving the first on the stack);`stringifies the code block, and".~"+ appends.~to it;- finally,
=compares the resulting string with the input (which is pushed on the stack as a string by the GolfScript interpreter before the program starts) and returns1if they match and0if they don't.