g.hatsevich at gmail.com (2018-03-18T15:04:18.745Z)
"This would remove the challenge and actively worsen their learning
process" -- this is not true. You can see it e.g. by looking at the
specific task I was talking about:
"Given a string, find the shortest possible string which can be achieved by
adding characters to the end of initial string to make it a palindrome."
This is my code for this task:
function buildPalindrome(s){
String.prototype.reverse=function(){
return this.split('').reverse().join('')
}
function isPalindrome(s){
return s===s.reverse()
}
for (i=0;i<s.length;i++){
first=s.slice(0,i);
rest=s.slice(i);
if(isPalindrome(rest)){
return s+first.reverse()
}
}
}
As you see, the essence of this challenge is not in the process of
reversing a string. Having a reverse() method just makes the code more
readable -- comparing to alternative when one would have to write
.split('').reverse().join('') each time instead of just .reverse()g.hatsevich at gmail.com (2018-03-18T15:03:26.043Z)
"This would remove the challenge and actively worsen their learning
process" -- this is not true. You can see it e.g. by looking at the
specific task I was talking about:
"Given a string, find the shortest possible string which can be achieved by
adding characters to the end of initial string to make it a palindrome."
This is my code for this task:
function buildPalindrome(s){
String.prototype.reverse=function(){
return this.split('').reverse().join('')
}
function isPalindrome(s){
return s===s.reverse()
}
for (i=0;i<s.length;i++){
first=s.slice(0,i);
rest=s.slice(i);
if(isPalindrome(rest)){
return s+first.reverse()
}
}
}
As you see, the essence of this challenge is not in the process of
reversing a string. Having a reverse() method just makes the code more
readable -- comparing to alternative when one would have to write
.split('').reverse().join('') each time instead of just .reverse()g.hatsevich at gmail.com (2018-03-18T15:02:59.148Z)
"This would remove the challenge and actively worsen their learning
process" -- this is not true. You can see it e.g. by looking at the
specific task I was talking about:
"Given a string, find the shortest possible string which can be achieved by
adding characters to the end of initial string to make it a palindrome."
This is my code for this task:
function buildPalindrome(s){
String.prototype.reverse=function(){
return this.split('').reverse().join('')
}
function isPalindrome(s){
return s===s.reverse()
}
for (i=0;i<s.length;i++){
first=s.slice(0,i);
rest=s.slice(i);
if(isPalindrome(rest)){
return s+first.reverse()
}
}
}
As you see, the essence of this challenge is not in the process of
reversing a string. Having a reverse() method just makes the code more
readable -- comparing to alternative when one would have to write
.split('').reverse().join('') each time instead of just .reverse()
"This would remove the challenge and actively worsen their learning process" -- this is not true. You can see it e.g. by looking at the specific task I was talking about: "Given a string, find the shortest possible string which can be achieved by adding characters to the end of initial string to make it a palindrome." This is my code for this task: function buildPalindrome(s){ String.prototype.reverse=function(){ return this.split('').reverse().join('') } function isPalindrome(s){ return s===s.reverse() } for (i=0;i<s.length;i++){ first=s.slice(0,i); rest=s.slice(i); if(isPalindrome(rest)){ return s+first.reverse() } } } As you see, the essence of this challenge is not in the process of reversing a string. Having a reverse() method just makes the code more readable -- comparing to alternative when one would have to write .split('').reverse().join('') each time instead of just .reverse() On Sun, Mar 18, 2018 at 2:38 PM, Frederick Stark <coagmano at gmail.com> wrote: > The point of a coding task for a beginner is to practice their problem > solving skills to solve the task. This would remove the challenge and > actively worsen their learning process > > > On Mar 18 2018, at 6:26 pm, Grigory Hatsevich <g.hatsevich at gmail.com> > wrote: > > > My use case is solving coding tasks about palindromes on codefights.com. > Not sure if that counts as "real-world", but probably a lot of beginning > developers encounter such tasks at least once. > > > > > On Sun, 18 Mar 2018 06:41:46 +0700, Mathias Bynens <mathias at qiwi.be> > wrote: > > So far no one has provided a real-world use case. > > On Mar 18, 2018 10:15, "Mike Samuel" <mikesamuel at gmail.com > <https://link.getmailspring.com/link/[email protected]/0?redirect=mailto%3Amikesamuel%40gmail.com&recipient=Zy5oYXRzZXZpY2hAZ21haWwuY29t>> > wrote: > > Previous discussion: https://esdiscuss.org/topic/wiki-updates-for-string- > number-and-math-libraries#content-1 > <https://link.getmailspring.com/link/[email protected]/1?redirect=https%3A%2F%2Fesdiscuss.org%2Ftopic%2Fwiki-updates-for-string-number-and-math-libraries%23content-1&recipient=Zy5oYXRzZXZpY2hAZ21haWwuY29t> > > """ > String.prototype.reverse(), as proposed, corrupts supplementary > characters. Clause 6 of Ecma-262 redefines the word "character" as "a > 16-bit unsigned value used to represent a single 16-bit unit of text", that > is, a UTF-16 code unit. In contrast, the phrase "Unicode character" is used > for Unicode code points. For reverse(), this means that the proposed spec > will reverse the sequence of the two UTF-16 code units representing a > supplementary character, resulting in corruption. If this function is > really needed (is it? for what?), it should preserve the order of surrogate > pairs, as does java.lang.StringBuilder.reverse:download.oracle.com/ > javase/7/docs/api/java/lang/StringBuilder.html#reverse() > <https://link.getmailspring.com/link/[email protected]/2?redirect=http%3A%2F%2Fdownload.oracle.com%2Fjavase%2F7%2Fdocs%2Fapi%2Fjava%2Flang%2FStringBuilder.html%23reverse()&recipient=Zy5oYXRzZXZpY2hAZ21haWwuY29t> > """ > > On Sat, Mar 17, 2018 at 1:41 PM, Grigory Hatsevich <g.hatsevich at gmail.com > <https://link.getmailspring.com/link/[email protected]/3?redirect=mailto%3Ag.hatsevich%40gmail.com&recipient=Zy5oYXRzZXZpY2hAZ21haWwuY29t>> > wrote: > > Hi! I would propose to add reverse() method to strings. Something > equivalent to the following: > > String.prototype.reverse = function(){ > return this.split('').reverse().join('') > } > > It seems natural to have such method. Why not? > > > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > <https://link.getmailspring.com/link/[email protected]/4?redirect=mailto%3Aes-discuss%40mozilla.org&recipient=Zy5oYXRzZXZpY2hAZ21haWwuY29t> > https://mail.mozilla.org/listinfo/es-discuss > <https://link.getmailspring.com/link/[email protected]/5?redirect=https%3A%2F%2Fmail.mozilla.org%2Flistinfo%2Fes-discuss&recipient=Zy5oYXRzZXZpY2hAZ21haWwuY29t> > > > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > [image: Open Tracking] -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180318/ed8aaa69/attachment-0001.html>