Narcissist: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
m (→‎{{header|Raku}}: Fix code and comment: Perl 6 --> Raku)
Line 449: Line 449:
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.
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.
Note how the code takes advantage of Raku'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>
<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>
Line 455: Line 455:
{{out}}
{{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.}}'
<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"
$ raku -e "$narcissist" <<<"$narcissist"
Beautiful!
Beautiful!
$ perl6 -e "$narcissist" <<<"$narcissist # a comment ruining it all"
$ raku -e "$narcissist" <<<"$narcissist # a comment ruining it all"
Not my type.
Not my type.
</pre>
</pre>