Narcissist: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
SqrtNegInf (talk | contribs) 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 |
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.}}' |
||
$ |
$ raku -e "$narcissist" <<<"$narcissist" |
||
Beautiful! |
Beautiful! |
||
$ |
$ raku -e "$narcissist" <<<"$narcissist # a comment ruining it all" |
||
Not my type. |
Not my type. |
||
</pre> |
</pre> |