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

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

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