Narcissist: Difference between revisions

Content added Content deleted
(Added UNIX Shell example.)
(Added Kotlin)
Line 211: Line 211:
WScript.Echo(self === whatever ? "Accept" : "Reject");
WScript.Echo(self === whatever ? "Accept" : "Reject");
</lang>
</lang>

=={{header|Kotlin}}==
<lang scala>// version 1.1.0 (run on Windows 10)

fun main(args: Array<String>) {
val text = java.io.File("narcissist.kt").readText()
println("Enter the number of lines to be input followed by those lines:\n")
val n = readLine()!!.toInt()
val lines = Array<String>(n) { readLine()!! }
if (lines.joinToString("\r\n") == text) println("\naccept") else println("\nreject")
}</lang>
First run (pasting in program text):
{{out}}
<pre>
Enter the number of lines to be input followed by those lines:

9
// version 1.1.0 (run on Windows 10)

fun main(args: Array<String>) {
val text = java.io.File("narcissist.kt").readText()
println("Enter the number of lines to be input followed by those lines:\n")
val n = readLine()!!.toInt()
val lines = Array<String>(n) { readLine()!! }
if (lines.joinToString("\r\n") == text) println("\naccept") else println("\nreject")
}

accept
</pre>
Second run (entering any old rubbish):

{{out}}
<pre>
Enter the number of lines to be input followed by those lines:

1
the quick brown fox

reject
</pre>


=={{header|Liberty BASIC}}==
=={{header|Liberty BASIC}}==