Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Recursive programs

Name: Anonymous 2011-05-30 20:08

I decided to write a program that printed itself, and I couldn't.

I pose to you this challenge, /prog/

Name: Anonymous 2011-05-30 20:11

http://en.wikipedia.org/wiki/Quine_(computing)
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))

Next.

Name: Anonymous 2011-05-30 20:13


(EVAL (SETQ X '`(EVAL (SETQ X ',X))))

Name: Anonymous 2011-05-31 1:01

Name: Anonymous 2011-05-31 1:12

>>2
pronounced 'queen'.

Name: Anonymous 2011-05-31 1:43

#include <stdio.h>
#include <string.h>

int main(void)
{
  FILE *prog = fopen("writemyself.c","r");
  char *buffer = malloc(sizeof(char) * 30);
  memset(buffer, '\0', sizeof(char) * 30);
  while (fscanf(prog,"%s", buffer))
  {
    fprintf(stderr, "%s", buffer);
    memset(buffer, '\0', sizeof(char) *30);
  }
  return 0;
}

Name: Anonymous 2011-05-31 1:47

print open(__file__).read(),

Name: Anonymous 2011-05-31 2:05

>>6

This is ridiculously bad, even per imageboard standards.

Name: Anonymous 2011-05-31 2:23

>>8
Not meant to be clever or anything. Why, what's wrong with it?

Name: Anonymous 2011-05-31 2:43

>>9
There's more than 30 characters in that source snippet. Your buffer isn't big enough.

Name: Anonymous 2011-05-31 3:09

>>10
I considered that, but using %s with scanf grabs characters up to white space. So it would stop after each word, making my buffer plenty big.

Name: Anonymous 2011-05-31 4:12

>>11

You also never free'd your buffer.

Didn't your professor ever tell you to free your mallocs?

Name: Anonymous 2011-05-31 4:46

>>12

not to mention he is using dynamic allocation for a small buffer with known size

Name: Anonymous 2011-05-31 5:13

>>12
Fuck

>>13
Also, this isn't something any professor's talked about, though I've seen this discussed here. Alternatives to allocating the necessary space? Differences?

Name: Anonymous 2011-05-31 5:50

>>14
Alternatives to allocating the necessary space?
char buffer[30];
Hurrrrrr.

Name: Anonymous 2011-05-31 8:57

>>6,7
Quines aren't allowed to read their source files as input.

Name: Anonymous 2011-05-31 11:17

>>16
Says who, fagstorm?

Name: Anonymous 2011-05-31 11:22

>>17
Do you eat out your mother with that mouth?

Name: Anonymous 2011-05-31 11:26

>>17
What kind of challenge is it then? Also try it with a compiled language when >>6 is not called "writemyself.c".
Also:
quine: /kwi:n/ /n./ [from the name of the logician Willard van Orman Quine, via Douglas Hofstadter] A program that generates a copy of its own source text as its complete output.
i.e., not one that just reads its source text (in which case it is not a generated copy of its source text).

Name: Anonymous 2011-05-31 11:37

Here's 3 CL ones:

""

1

(let ((let '`(let ((let ',let)) ,let)))
       `(let ((let ',let)) ,let))

Name: Anonymous 2011-05-31 12:15

>>18
fuck you faggot

Name: Anonymous 2011-05-31 12:21

You can't do this in a compiled language.

Name: Anonymous 2011-05-31 12:24

>>18
No, just my grandma. My mother's dead. So's my grandma, but that's not the point.

Name: Anonymous 2011-05-31 13:54

Ruby, doing a famous quine trick, only obfuscated.
_="_=%p;$><<_%%_";$><<_%_

Name: Anonymous 2011-05-31 14:08

>>22
CL is compiled, Haskell is compiled.

Name: Anonymous 2011-05-31 14:25

>>22
Yes you can. Look up the fucking definition.

Name: Anonymous 2011-05-31 14:28

>>26
No you can't. Write one in C, then.

Name: Anonymous 2011-05-31 14:55

>>27
Just look it up. A quine does not use its source file as input, by definition.
http://www.nyx.net/~gthompso/quine.htm
char*f="char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c";main(){printf(f,34,f,34,10);}

Name: Anonymous 2011-05-31 15:13

>>9

The file doesn't have to be named writemyself.c.

Name: Anonymous 2011-05-31 15:22

sh quine:
cat "$0"

Name: Anonymous 2011-05-31 15:23

>>28
That doesn't work fag you fail lol.

Name: Anonymous 2011-05-31 15:49

>>24

I had no idea how much Ruby could make itself look like perl... until now.

Name: Anonymous 2011-05-31 16:27

A quine is a computer program which takes no input and produces a copy of its own source code as its only output.


MOV 0, 1

Name: Anonymous 2011-05-31 17:15

#define qnb "You are now breathing manually."
#include <stdio.h>
#define b "\\"
#define n "\n"
#define q "\""
#define bb "b"
#define nn "n"
#define qq "q"
#define bn "#define "
#define nb " "
#define bbb "#include <stdio.h>"
#define nnn "int main(void) { puts("
#define qqq "); return 0; }"
#define bnq "bn qq nn bb nb q qnb q n bbb n bn bb nb q b b q n bn nn nb q b nn q n bn qq nb q b q q n bn bb bb nb q bb q n bn nn nn nb q nn q n bn qq qq nb q qq q n bn bb nn nb q bn q n bn nn bb nb q nb q n bn bb bb bb nb q bbb q n bn nn nn nn nb q nnn q n bn qq qq qq nb q qqq q n bn bb nn qq nb q bnq q n nnn n bnq n qqq"
int main(void) { puts(
bn qq nn bb nb q qnb q n bbb n bn bb nb q b b q n bn nn nb q b nn q n bn qq nb q b q q n bn bb bb nb q bb q n bn nn nn nb q nn q n bn qq qq nb q qq q n bn bb nn nb q bn q n bn nn bb nb q nb q n bn bb bb bb nb q bbb q n bn nn nn nn nb q nnn q n bn qq qq qq nb q qqq q n bn bb nn qq nb q bnq q n nnn n bnq n qqq
); return 0; }

Name: Anonymous 2011-05-31 17:31

>>34
"You are now breathing manually."
I hate you, I'm suffering right now.

Name: !HfD2XMemw6 2011-05-31 18:23

Here's mine:



From obfuscated C contest.

Name: Anonymous 2011-05-31 19:05

>>36
Invalid C code.

Name: Anonymous 2011-05-31 19:21

>>37

It won one of the contest prizes.

Name: Anonymous 2011-05-31 20:01

I have developed a compile-time quine in C. Compilation instructions are in the transcript below.
$ cat anus.c
anus.c:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
compilation terminated due to -fmax-errors=1.
$ gcc -w -fmax-errors=1 anus.c                    
anus.c:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
compilation terminated due to -fmax-errors=1.
$ gcc -w -fmax-errors=1 anus.c 2>&1 | diff anus.c -
$

Name: compile with gcc kimian.c 2011-05-31 20:04

>>39

kimian.c:1:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
kimian.c:1:46: warning: multi-character character constant
kimian.c:1:55: warning: character constant too long for its type

Name: Anonymous 2011-05-31 20:06

>>40
I couldn't get that to happen due to the ‘’ characters, it just spewed out several 'stray character \x380' or so errors without -fmax-errors.

Name: Anonymous 2011-05-31 20:09


quine.hs:2:37: parse error on input `)'

Name: Anonymous 2011-05-31 20:14

>>41
I suspect the --disable-nls configure flag may have something to do with this.

Name: Anonymous 2011-06-01 2:23

>>15
>>14 here

You fucking "faggot", I know that the code is different. What I meant is, how is it different internally?

Name: Anonymous 2011-06-01 5:19

the last stage  of autism turns you into gcc

Name: Anonymous 2011-06-01 5:32

>>44
1. Go back to the imageboards.
2. It's perfectly cromulent to use that in this situation.

Name: Anonymous 2011-06-01 8:16

>>46
fuck you faggot

Name: Anonymous 2011-06-01 11:32

I wrote a saner Ruby one.

puts DATA.read*2
__END__
puts DATA.read*2
__END__

Name: Anonymous 2011-06-01 12:55

>>48
Doesn't that count as ``input''?

Name: Anonymous 2011-06-01 13:51

>>48
Holy shit, why does ruby even exist? It's like it wants to be perl so hard that it's just a clone.

Name: Anonymous 2011-06-01 14:33

>>50
It's a frankenstein monster language with concepts from Smalltalk, Lisp and Perl, with Perlish (read: unreadable, write-only) syntax and lots of special case.
So, it has a lot in common with C++.

Name: Anonymous 2011-06-01 17:55

This is a 32 bit Linux ELF binary quine, it will output itself in binary.

0000000 457f 464c 0101 0001 0000 0000 0000 0000
0000010 0002 0003 0001 0000 8080 0804 0034 0000
0000020 00c0 0000 0000 0000 0034 0020 0002 0028
0000030 0004 0003 0001 0000 0000 0000 8000 0804
0000040 8000 0804 00a8 0000 00a8 0000 0005 0000
0000050 1000 0000 0001 0000 00a8 0000 90a8 0804
0000060 90a8 0804 0001 0000 0001 0000 0006 0000
0000070 1000 0000 0000 0000 0000 0000 0000 0000
0000080 a8b9 0490 8108 a8e9 0000 ba00 0160 0000
0000090 04b8 0000 bb00 0001 0000 80cd 01b8 0000
00000a0 bb00 0000 0000 80cd 0000 732e 7368 7274
00000b0 6174 0062 742e 7865 0074 642e 7461 0061
00000c0 0000 0000 0000 0000 0000 0000 0000 0000
*
00000e0 0000 0000 0000 0000 000b 0000 0001 0000
00000f0 0006 0000 8080 0804 0080 0000 0028 0000
0000100 0000 0000 0000 0000 0010 0000 0000 0000
0000110 0011 0000 0001 0000 0003 0000 90a8 0804
0000120 00a8 0000 0001 0000 0000 0000 0000 0000
0000130 0004 0000 0000 0000 0001 0000 0003 0000
0000140 0000 0000 0000 0000 00a9 0000 0017 0000
0000150 0000 0000 0000 0000 0001 0000 0000 0000
0000160

Name: Anonymous 2011-06-01 18:41

>>28
This works, but only if you add
#include <stdio.h>

Name: Anonymous 2011-06-01 18:47

>>52
That's hex.

Name: Anonymous 2011-06-01 19:16

>>54
xxd -r

Name: Anonymous 2011-06-01 19:39

(function (){alert ("("+arguments.callee.toString()+")();");})();

Name: Anonymous 2011-06-01 19:49

>>56
In my browser's js engine, it's only a valid quine if it's formatted thusly:
(function () {
    alert("(" + arguments.callee.toString() + ")();");
})();


The More You Know

Name: Anonymous 2011-06-01 19:51

>>57
The more you realize that she wants to shove her dildo up your ass. I hope you enjoy wearing nylons you douche.

Name: Anonymous 2011-06-01 19:53

>>57
Yeah, I tested it in both FF and V8. Decided to go with the V8 one, because fuck the system is why.

Name: Anonymous 2011-06-01 19:59

>>56,57
You can also remove the .toString().

Name: Anonymous 2011-06-01 20:08

>>60
It still gets called when concatenated to the string with +, so it may as well be there.

Don't change these.
Name: Email:
Entire Thread Thread List