Jump to content

Narcissist: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 94:
Only checks the first line of stdin:
<lang lisp>#1=(PRINT (EQUAL (WRITE-TO-STRING '#1# :CIRCLE 1) (READ-LINE *STANDARD-INPUT*)))</lang>
 
=={{header|D}}==
<lang D>import std.file; import std.stdio; import std.string; void main() { auto source = readText("narcissist.d").chomp; auto input = readln().chomp(); if (source == input) writeln("accept"); else writeln("reject"); }</lang>
Line 275 ⟶ 276:
 
{{works with|Julia|1.2}}
 
=={{header|Julia}}==
<lang julia>mysource = Base.read(Base.source_path(), String)
Line 367 ⟶ 369:
<pre>narcissist() = {input() == narcissist;}
1</pre>
 
=={{header|Perl}}==
<lang perl># this is file narc.pl
Line 373 ⟶ 376:
Run:
<lang>perl narc.pl < narc.pl</lang>
 
=={{header|Perl 6}}==
 
For the narcissist to work you must be very careful with whitespace. The following version works if it is given to standard input as exactly one line terminated by a newline character.
 
Note how the code takes advantage of Perl 6's ability to nest quoting delimiters.
 
<lang perl6>EVAL my $self = q{say slurp() eq q[EVAL my $self = q{]~$self~q[}]~10.chr ?? q{Beautiful!} !! q{Not my type.}}</lang>
 
{{out}}
<pre>$ narcissist='EVAL my $self = q{say slurp() eq q[EVAL my $self = q{]~$self~q[}]~10.chr ?? q{Beautiful!} !! q{Not my type.}}'
$ perl6 -e "$narcissist" <<<"$narcissist"
Beautiful!
$ perl6 -e "$narcissist" <<<"$narcissist # a comment ruining it all"
Not my type.
</pre>
 
=={{header|Phix}}==
Line 456 ⟶ 443:
#t
</lang>
 
=={{header|Perl 6Raku}}==
(formerly Perl 6)
 
For the narcissist to work you must be very careful with whitespace. The following version works if it is given to standard input as exactly one line terminated by a newline character.
 
Note how the code takes advantage of Perl 6's ability to nest quoting delimiters.
 
<lang perl6>EVAL my $self = q{say slurp() eq q[EVAL my $self = q{]~$self~q[}]~10.chr ?? q{Beautiful!} !! q{Not my type.}}</lang>
 
{{out}}
<pre>$ narcissist='EVAL my $self = q{say slurp() eq q[EVAL my $self = q{]~$self~q[}]~10.chr ?? q{Beautiful!} !! q{Not my type.}}'
$ perl6 -e "$narcissist" <<<"$narcissist"
Beautiful!
$ perl6 -e "$narcissist" <<<"$narcissist # a comment ruining it all"
Not my type.
</pre>
 
=={{header|REXX}}==
Line 485 ⟶ 489:
if (lines.mkString("\r\n") == text) println("\naccept") else println("\nreject")
}</lang>
 
=={{header|Sidef}}==
<lang ruby>say (File.new(__FILE__).open_r.slurp == ARGF.slurp);</lang>
Line 536 ⟶ 541:
<pre>$ txr narcissist.txr narcissist.txr
1</pre>
 
=={{header|UNIX Shell}}==
<lang bash>cmp "$0" >/dev/null && echo accept || echo reject</lang>
 
=={{header|VBA}}==
Line 581 ⟶ 589:
Debug.Print IIf(flag, 1, 0)
End Sub</lang>
=={{header|UNIX Shell}}==
<lang bash>cmp "$0" >/dev/null && echo accept || echo reject</lang>
 
=={{header|zkl}}==
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.