top | item 46447618

(no title)

nickdrozd | 2 months ago

I gave a few attempts with ChatGPT and DeepSeek. Neither of them could get it right. So this goalpost can remain in place for the time being.

(I am assuming that the task is actually possible to accomplish. If it isn't possible, then it isn't a very good goalpost!)

discuss

order

bediger4000|2 months ago

It should be possible. nroff macro language has looping, string interpolation, functions and if/then/else. That macro language should be turing complete. People have written file-infecting virus malware with it, I believe, which indicate that a quine should be possible. I personally have made several attempts at an nroff quine over the years with no success.

If it's not possible, I'd love to see an explanation, so that task can quite weighing on me.

nickdrozd|2 months ago

Here is an attempt:

  .de Q
  .nf
  .na
  .pso awk 'BEGIN{bs=sprintf("%c",92); pre=bs"&"} {out=pre; for(i=1;i<=length($0);i++){c=substr($0,i,1); if(c==bs) out=out bs bs; else out=out c} print out}' "\n[.F]"
  .ex
  ..
  .Q
Invoke with:

  nroff -U -Tascii quine.roff | sed -Ez '$ s/\n+$//'
Possibly relies too much on awk + sed. So maybe not A+, but better than nothing.