Talk:Palindrome detection: Difference between revisions

(→‎Prolog: experimenting prolog...)
 
(20 intermediate revisions by 8 users not shown)
Line 7:
: I think what is meant is that the function itself shouldn't ignore spaces or punctuations, but if using the given example, the test code must remove spaces and convert to either uppercase or lowercase, because otherwise the example isn't a character-wise palindrome. I think it would make more sense to use some example which already is a character-wise palindrome by itself, say the German word "nennen" (to name). --[[User:Ce|Ce]] 09:42, 6 December 2008 (UTC)
 
:: It is what I've meant... As example of palindrome I used "In girum imus ..." just because it is the longest I know by heart: the "ignore or strip spaces" refers to that example as I wrote there; looking at the code it is clear what I've meant. According to me a function that tests the palindromicity of a "arbitrary" sequence is more general than one that "ignores" by design some characters; you can use the function you wrote to test palindromicity on "In girum imus nocte ...", provided that you strip spaces and make the case of all letters the same... outside the function, e.g. is_palindrome(stripchars(string)), and write stripchars according to any need. In the codes, I did it by hand coding the test string as "ingirumimusnocte...", that is less readable, but in this way I had not to write a stripchars function just to test! --[[User:ShinTakezou|ShinTakezou]] 00:44, 7 December 2008 (UTC)
 
:: And hey, my english is bad, but not so bad: I've forgot it, but I wrote ''To do your test with it, you must make it all the same case and strip spaces.'', where the "it" refers to the "In girum imus..." palindrome, and ''to do your test with it'' means ... :D --[[User:ShinTakezou|ShinTakezou]] 00:44, 7 December 2008 (UTC)
Line 14:
 
:::: Got your point. Chances there are that my ''main'' contribute is in the C language :) --[[User:ShinTakezou|ShinTakezou]] 00:25, 8 December 2008 (UTC)
 
::: I'm afraid I have to disagree with ShinTakezou on this. The normal, non-computational definition of a palindrome is a string that reads the same forwards and backwards while ignoring spaces, case and punctuation. So the computational definition should be the same for this task. Especially since stripping non-word chars is a common subtask. If the input has to be massaged manually for a checker to work, it's not much of a checker. :-) And checking only single-word strings is really just a degenerate case. --[[User:Snoman|Snoman]] 00:43, 13 July 2010 (UTC)
 
:::: Since "non-computational" systems like human brain can recognize palindromicity in many different context, and humans do not read strings, but sentences/words, and blanks/punctuations are "naturally" ignored (and difference between upper and lowercase), being just a way to make it easier to recognize words and read sentences. Computational systems can identify as "naturally different" "A" and "a", and spaces/tabs/puncts are not just blank or "spurious" symbols to help reading, they are existing real symbols for the system. A general "computational" palindromicity test can operate on any symbol a computer can recognize as such (even on "unreadable" sequences of bytes, provided you avoid '\0' in C and similar langs where a string is '\0' terminated). To go back and forth to the "non-computational" "sight", it is enough to add/remove stripblanks, strippunct, lowercase/uppercase and other transformation able to make computer ignores the difference human "naturally" can ignore. But it is not necessary, and the general palindromicity approach is well, more general, and so, better since can be used '''also''' for your "non-computational" definition. --[[User:ShinTakezou|ShinTakezou]] 06:17, 13 July 2010 (UTC)
 
::::: Sure, understood. I think people are just pointing out that the task description was not as clear to some of us as you wanted it to be, partly because the term "palindrome" is not actually defined in the task. The linked Wikipedia article focuses mostly on natural language palindromes, as does the Latin example. As a linguist myself, I admit I find those more interesting than formal strings, and both are valid. For your more restrictive and computationally general idea, maybe specifying a formal mathematical statement of a palindromic sequence would have helped. In any case, the one type of solution is convertible to the other with a little extra string handling, so it's not a huge deal. And thanks for the explanations of your POV. --[[User:Snoman|Snoman]] 08:39, 13 July 2010 (UTC)
::::::: The wikipedia's article was linked just to clarify the sense of palindromicity, but my initial wording should make it clear that the task was thought with "computer vision" in mind: <cite>check if a '''sequence of characters (or bytes)''' is a palindrome or not</cite>; <cite>It is not mandatory to handle properly encodings</cite>; <cite>The function must not ignore spaces and punctuations</cite>; then, for the given example, I specified <cite>To do your test with it, you must make it all the same case and strip spaces.</cite>. Anyway, if people are happier with other defintions, it's ok to change the task description, as far as the rewriting does not "invalidate" all the codes (or people should rewrite the codes too for task compliance) --[[User:ShinTakezou|ShinTakezou]] 18:13, 13 July 2010 (UTC)
 
:::::: I would recommend a rephrasing:
:::::: "This task requires a modular design: You must implement a function which tests if an arbitrary sequence of characters or bytes is a palindrome. You must also implement a wrapper which normalizes text, removing spaces, case differences, and punctuation." --[[User:Rdm|Rdm]] 14:21, 13 July 2010 (UTC)
::::::: If people agree, go for it. I don't see my sentences ambiguous anyway. --[[User:ShinTakezou|ShinTakezou]] 18:13, 13 July 2010 (UTC)
:::::::: I do not think your sentences were ambiguous, either. They do, however, allow for a paradoxical interpretation, from some people's points of view. And its easy enough to change. --[[Special:Contributions/159.54.131.7|159.54.131.7]] 18:34, 13 July 2010 (UTC)
 
----
 
Looking at the Perl, I added case/space/punctuation handling to the first 3, an easy 1-line change to each that doesn't change the existing functionality. Also corrected the spelling of "palendrome" in the regex version. :-) --[[User:Snoman|Snoman]] 00:43, 13 July 2010 (UTC)
 
==Haskell recursive solution note==
Line 108 ⟶ 124:
 
So now I am convinced I can't do it, and I'm wondering if it exists somewhere a Prolog Guru able to enlighten my poor logic at pro'''log'''-'''ic'''. --[[User:ShinTakezou|ShinTakezou]] 01:24, 11 February 2009 (UTC)
 
 
====Better reading of the GNU Prolog manual====
 
They worked... The meaning of True when feeded with a palindrome was that one (and only) solution is true, while the ? just asked for the search of the next solution; the ''no'' that is output thereafter, means there are no more solutions! When it is not a palindrome, it simply says that there are not solution (no), it does not mean that the "predicate" returned false... it means that the problem can't have a solution (i.e., the word is not palindrome). --[[User:ShinTakezou|ShinTakezou]] 14:32, 11 February 2009 (UTC)
 
== REXX ==
 
why was "remove" changed to "rename"?? --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 04:26, 18 May 2013 (UTC)
 
I had a short-lived brilliant idea to remove 1/3 of the subroutine, but it didn't work, so I reinstated the original statement, but I re-typed the comment incorrectly. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 05:41, 18 May 2013 (UTC)
 
== COMPRESS in REXX ==
 
What is compress? Which Rexx has it??
Would space(...,0) do the job??? --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 08:40, 14 September 2015 (UTC)
 
: The '''compress''' BIF is supported by the ARexx REXX interpreter, as well as Regina when the appropriate '''options''' are specified, and also in Regina when Regina is executing on (or an equivalent) Commodore Amiga 1000 (A1000), known commonly as the Amiga. &nbsp; The '''compress''' BIF is documented in the Regina (PDF) documentation. &nbsp; I can't speak to any other REXXes that may support that BIF. &nbsp; As far as I know, '''compress''' is equivalent to '''space(xxx,0)''', but I don't know how it treats whitespace other than blanks. &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 18:54, 14 September 2015 (UTC)
 
:: In Regina doc I read that all blanks are removed. So does SPACE(xxx,0) as far as I know.
Does ARexx >not< support space(xxx,0)? --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 19:41, 14 September 2015 (UTC)
 
::: ARexx does support &nbsp; '''space(xxx,0)'''. &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 04:31, 3 March 2016 (UTC)
 
:::: But Compress() is more versatile. -- [[User:Idrougge|Idrougge]] ([[User talk:Idrougge|talk]]) 09:56, 22 March 2017 (UTC)
 
::::: That may be true, but the &nbsp; '''compress''' &nbsp; BIF isn't supported by most of the REXX interpreters available. &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 21:42, 28 March 2017 (UTC)
 
== Why do so many solutions fail to solve both extra credit tasks? ==
 
From my experience trying to do it in R, supporting Unicode while stripping punctuation and white space is hard, but is it really so hard that hardly any of our solutions have done it?--[[User:ReeceGoding|ReeceGoding]] ([[User talk:ReeceGoding|talk]]) 20:28, 16 July 2020 (UTC)
331

edits