First commit of partial RosettaCode contents.

Pushing this for testing purposes. Lots of work still needed.
This commit is contained in:
Ingy döt Net 2013-04-08 13:02:41 -07:00
commit 1e05ecd7ee
781 changed files with 9080 additions and 0 deletions

View file

@ -0,0 +1,9 @@
Quoting from the [http://esolangs.org/wiki/Narcissist Esolangs wiki page]:
<blockquote>
A '''narcissist''' (or '''Narcissus program''') is the decision-problem version of a [[quine]].
</blockquote><blockquote>
A quine, when run, takes no input, but produces a copy of its own source code at its output. In contrast, a narcissist reads a string of symbols from its input, and produces no output except a "1" or "accept" if that string matches its own source code, or a "0" or "reject" if it does not.
</blockquote>
For concreteness, in this task we shall assume that symbol = character. The narcissist should be able to cope with any finite input, whatever its length. Any form of output is allowed, as long as the program always halts, and "accept", "reject" and "not yet finished" are distinguishable.

View file

@ -0,0 +1 @@
extern void*stdin;main(){ char*p = "extern void*stdin;main(){ char*p = %c%s%c,a[300],b[300];sprintf(a,p,34,p,34);fgets(b,300,stdin);putchar(48+!strcmp(a,b)); }",a[300],b[300];sprintf(a,p,34,p,34);fgets(b,300,stdin);putchar(48+!strcmp(a,b)); }

View file

@ -0,0 +1 @@
: narcissist [ source ] sliteral compare 0= ;

View file

@ -0,0 +1,39 @@
package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
)
func main() {
s := fmt.Sprintf("%s%c%s%c\n", x, 0x60, x, 0x60)
in, _ := ioutil.ReadAll(os.Stdin)
if bytes.Equal(in, []byte(s)) {
fmt.Println("Accept")
} else {
fmt.Println("Reject")
}
}
var x = `package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
)
func main() {
s := fmt.Sprintf("%s%c%s%c\n", x, 0x60, x, 0x60)
in, _ := ioutil.ReadAll(os.Stdin)
if bytes.Equal(in, []byte(s)) {
fmt.Println("Accept")
} else {
fmt.Println("Reject")
}
}
var x = `

View file

@ -0,0 +1 @@
package main; import "os"; import "fmt"; import "bytes"; import "io/ioutil"; func main() {ios := "os"; ifmt := "fmt"; ibytes := "bytes"; iioutil := "io/ioutil"; zero := "Reject"; one := "Accept"; x := "package main; import %q; import %q; import %q; import %q; func main() {ios := %q; ifmt := %q; ibytes := %q; iioutil := %q; zero := %q; one := %q; x := %q; s := fmt.Sprintf(x, ios, ifmt, ibytes, iioutil, ios, ifmt, ibytes, iioutil, zero, one, x); in, _ := ioutil.ReadAll(os.Stdin); if bytes.Equal(in, []byte(s)) {fmt.Println(one);} else {fmt.Println(zero);};}\n"; s := fmt.Sprintf(x, ios, ifmt, ibytes, iioutil, ios, ifmt, ibytes, iioutil, zero, one, x); in, _ := ioutil.ReadAll(os.Stdin); if bytes.Equal(in, []byte(s)) {fmt.Println(one);} else {fmt.Println(zero);};}

View file

@ -0,0 +1 @@
var code='var q=String.fromCharCode(39);print("var code=" + q + code + q + "; eval(code)" == readline())'; eval(code)

View file

@ -0,0 +1 @@
perl narc.pl < narc.pl

View file

@ -0,0 +1,2 @@
# this is file narc.pl
print do { local $/; open 0, $0 or die $!; <0> } eq <> ? "accept" : "reject"

View file

@ -0,0 +1,2 @@
(de narcissist (Str)
(= Str (str narcissist)) )

View file

@ -0,0 +1,7 @@
import sys
with open(sys.argv[0]) as quine:
code = raw_input("Enter source code: ")
if code == quine.read():
print("Accept")
else:
print("Reject")

View file

@ -0,0 +1 @@
/*REXX*/ say word('reject accept',1+(arg(1)=sourceline(1)))

View file

@ -0,0 +1 @@
/*REXX*/ say arg(1)=sourceline(1)

View file

@ -0,0 +1 @@
s = "s = %s%s%s; puts(gets.chomp == (s %% [34.chr, s, 34.chr]) ? 'accept' : 'reject')"; puts(gets.chomp == (s % [34.chr, s, 34.chr]) ? 'accept' : 'reject')

View file

@ -0,0 +1 @@
apply {s {puts [expr {[gets stdin]eq[list {*}$s $s]}]}} {apply {s {puts [expr {[gets stdin]eq[list {*}$s $s]}]}}}

View file

@ -0,0 +1 @@
apply {{} {puts [expr {[gets stdin] eq [info level 0]}]}}