Talk:Palindrome

From Esolang
Jump to navigation Jump to search

Just wondering, what qualifies as a palindrome program? Does just each line have to be the same backwards like

abccba
deffed
ghiihg

or does the entire program have to be backwards like

abcdef
ghiihg
fedcba

?

If the first one counts, (like this program) wouldn't a brainfuck program with one command on each line count as a palindrome program?

Oh, and what about stuff like "{\*/}"? It's symmetrical, but not the same backwards.

--BodyTag 09:16, 10 Oct 2005 (GMT)

  • My view on this: a BF program with one command on each line doesn't count as a palindrome, because the newline character isn't BF code. A BF palindrome has to be a palindrome from the start to the end of the program. Something like {\*/} is not a palindrome but something else. --Aardwolf 12:10, 10 Oct 2005 (GMT)
I totally agree with Aardwolf. The first program example is not a palindrome itself, but each individual code line is.--Rune 12:23, 10 Oct 2005 (GMT)
I agree that a brainfuck program with one command on each line shouldn't be counted as a palindrome program, but that's my point, what exactly qualifies as a palindrome program? Each line in a brainfuck program with one command on each line IS the same backwards, If the entire program has to be the exactly same backwards, and not just each line, the obfuscated C there is nowhere near being a palindrome program. Or are the "rules" different for different languages, and who decides what's allowed? Sorry, I'm in my discussion mood. --BodyTag 13:04, 10 Oct 2005 (GMT)
Well, don't know who has defined it, as well, perhaps every language should use the same 'rules', and in some languages it's just not possible to make them. The esowiki article says that a palindrome program's source is the exactly same when you reverse it. In that case a brainfuck program with each instruction separated from each other with a new-line character is a palindrome, in case the program is exactly same when it's reversed. :) Speaking of which, I have never seen a real palindrome program.. Perhaps they're quite hard to write. --User:Keymaker
The obfuscated C program is definately not a palindrome, but most of its code lines are. You have to be able to reverse the entire program, character by character. Here's an example of a palindrome program in Kipple:
o<"
SATOR
AREPO
TENET
OPERA
ROTAS
"<o
This program prints out a famous palindrome, but according to the palindrome article it is a trivial palindrome program because only half the instructions are actually executed. non-trivial palindrome programs are much harder to make. I've never seen one. --Rune 14:12, 10 Oct 2005 (GMT)
Further to the commentary above, we'd also need to define what a palindrome means in a two-dimensional language (or even a multi-dimensional language). I think a general definition would have to say that the program is symmetric (character-wise) around some point/axis/plane. This works for a one dimensional language if we treat newlines as just another character (and ignore the fact they start a new line, introducing a pseudo-second-dimension). For more dimensions it's unclear whether symmetry should just to the first degree (around one line/plane) or to the maximum degree (so for a 2D language the program would have to be square with four degrees of reflectional symmetry and four degrees of rotational symmetry). --Safalra 17:59, 10 Oct 2005 (GMT)
That kind of program will be insanely hard, if even possible. At least if every instruction must be executed or even if the instruction pointer just needs to go through them. Can't think of any 'useful' program either. Something simple printing is possible, but then for example a program may set values to cells after the output is already done. I mean like this kind of brainfuck program;
++++.++++
that would increase the current cell by four, output it, and then increase the cell without any good reason.. But anyways, as said in a comment above, this whole palindrome thing needs more specific defining. Perhaps several cases of palindromic program types? --User:Keymaker
And wouldn't a brainfuck program with loops have to have unmatched brackets to be a palindrome? Example, [-] backwards is ]-[. [[-]>] is ]>]-[[. Any loop turns into an unmatched nightmare of commands. --BodyTag 18:59, 10 Oct 2005 (GMT)
You're right.. The palindromic brainfuck program can't have loops at all, if we assume that the program must be itself reversed on the character-level. However, if we just look the program visually and don't mind about the character-level, then in that case program '>[.]<' is a palindrome. As said before, this is confusing! :) --User:Keymaker
The following is a non-trivial 2D palindrome in Sansism under my definition of palindrome above. This one displays symmetry around a horizontal line. All instructions are executed. It outputs 'HELLO'. The right-hand side of the program is a generic symmetrical output routine.
                                                                                                   GG
                                                                                      G + G    G--G +
                                                       GG                              G-G  G  G   +G
>+++++++++++++++++++!!!!!#>#++++!++++!++++!++++!++++!-# G#!----!-------!!!+++##!!!!!##+ +G>!>.!G   --
                                                       GG                              G-G  G  G   +G
                                                                                      G + G    G--G +
                                                                                                   GG
If no-one objects, I'll make a new Wiki article called 'Symmetrical program' to cover programs like this in 2D languages. --Safalra 11:05, 13 Oct 2005 (GMT)
Sounds like a good idea. Or you could make a sub section in the Palindrome article, but it might be better to keep them separate. However, this kind of program is not restricted to 2D languages, just as regular palindromes are not restricted to 1D languages. Nice program, by the way! --Rune 12:06, 13 Oct 2005 (GMT)
Another thought, wouldn't that make a program on one line, as long as it's in a 2D language, a "Symmetrical program"? Example: 0"!dlroW ,olleH">:#,_@ in Befunge. I realize everyone's probably gonna say "the program itself has gotta be 2D, too," and I agree. I'm just saying you can never be too specific. OK, you can, but that's not the point. --BodyTag 16:04, 13 Oct 2005 (GMT)
Oh, and aren't all programs in unary palindromes? :P --BodyTag 07:18, 20 Oct 2005 (GMT)
No. The EOF symbol appears at the end, but not at the beginning. --Graue 13:09, 20 Oct 2005 (GMT)
Come on, you don't count EOF in, let's say, brainfuck. The EOF isn't part of the programs themselves, it's more like a technical limitation. Besides, it was meant as a joke :P --BodyTag 13:15, 20 Oct 2005 (GMT)
You got me -- the definition of a palindrome seems to implicitly exclude EOF from consideration. --Graue 13:25, 20 Oct 2005 (GMT)
EOF is not part of the program. When I write a program on paper, or here in the wiki, there is no EOF character. In fact, there is no EOF character when I store it on my hard drive either. The EOF character is appended to the program by the OS at run-time when it is read from disk. --Rune 14:03, 20 Oct 2005 (GMT)
If you count the EOF character in Unary, you have to count it in all languages. If you count the EOF character, no program in no language can be palyndrome (except the null program). If you don't count the EOF character, all Unary programs are palyndrome. --Aardwolf 14:45, 20 Oct 2005 (GMT)
Well, of course all programs in Unary are palindromes (though hardly very interesting ones). However, calling them programs is stretching it a bit. They are just jokes... --Rune 21:18, 20 Oct 2005 (GMT)

Question

Is

[]

a palindrome? --None1 (talk) 12:04, 9 October 2023 (UTC)