Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #24909 > unrolled thread
| Started by | jonas.thornvall@gmail.com |
|---|---|
| First post | 2014-06-18 12:39 -0700 |
| Last post | 2014-06-18 16:12 -0700 |
| Articles | 4 on this page of 24 — 4 participants |
Back to article view | Back to comp.lang.javascript
Can you change value of a substring? jonas.thornvall@gmail.com - 2014-06-18 12:39 -0700
Re: Can you change value of a substring? jonas.thornvall@gmail.com - 2014-06-18 13:09 -0700
Re: Can you change value of a substring? Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-18 23:18 +0200
Re: Can you change value of a substring? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-19 00:35 +0200
Re: Can you change value of a substring? jonas.thornvall@gmail.com - 2014-06-18 15:52 -0700
Re: Can you change value of a substring? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-06-18 16:14 -0700
Re: Can you change value of a substring? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-18 22:10 +0200
Re: Can you change value of a substring? jonas.thornvall@gmail.com - 2014-06-18 13:17 -0700
Re: Can you change value of a substring? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-18 22:52 +0200
Re: Can you change value of a substring? jonas.thornvall@gmail.com - 2014-06-18 14:03 -0700
Re: Can you change value of a substring? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-19 00:07 +0200
Re: Can you change value of a substring? jonas.thornvall@gmail.com - 2014-06-18 15:28 -0700
Re: Can you change value of a substring? jonas.thornvall@gmail.com - 2014-06-18 13:20 -0700
Re: Can you change value of a substring? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-18 23:22 +0200
Re: Can you change value of a substring? jonas.thornvall@gmail.com - 2014-06-18 14:40 -0700
Re: Can you change value of a substring? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-19 00:31 +0200
Re: Can you change value of a substring? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-18 23:42 +0200
Re: Can you change value of a substring? Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-19 00:13 +0200
Re: Can you change value of a substring? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-19 00:45 +0200
Re: Can you change value of a substring? Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-19 01:32 +0200
Re: Can you change value of a substring? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-19 09:43 +0200
Re: Can you change value of a substring? Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-19 01:48 +0200
Re: Can you change value of a substring? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-19 09:56 +0200
Re: Can you change value of a substring? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-06-18 16:12 -0700
Page 2 of 2 — ← Prev page 1 [2]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-06-19 09:43 +0200 |
| Message-ID | <XnsA35162DF977E8eejj99@194.109.133.133> |
| In reply to | #24933 |
Christoph Michael Becker <cmbecker69@arcor.de> wrote on 19 jun 2014 in comp.lang.javascript: > Thus I'd say numbers and strings are immutable, but arrays are not. Not really, as the members of the arrays are just variables. both var b = 'qqq'; and a[7] = 'rrr'; are likewize immutable. [I suspect that in applications, the array members are not even grouped together, but are handled the same as the simple variables.] -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2014-06-19 01:48 +0200 |
| Message-ID | <53a22539$0$6667$9b4e6d93@newsspool3.arcor-online.net> |
| In reply to | #24924 |
Stefan Ram wrote:
> Christoph Michael Becker <cmbecker69@arcor.de> writes:
The attribution of the following is missing.
>>> An analog clock and a human usually have hands,
>>> does that fact mean they have "something to do" with eachother?
>> Thumbs up! :)
>
> In fact they have so many things in common: Both have a
> mass, the mass is always between 1E-3 and 1E+3 kg, both
> exist on the earth, but not on the asteroid Proserpina, both
> have parts that are called »hands«, and and and. I can not
> enlist all that which they have in common!
>
> Hint: »having something to do with« does not mean »to be the
> same«.
Of course. However, finding *any* relationship doesn't mean much...
>> Consider passing a string as argument to a function; if the function is
>> able to actually change the string, the programmer has to be aware of
>
> A function can never change a string in any programming
> language, because a string is a value, just as a number.
I beg to differ. Consider C:
#include <stdlib.h>
#include <assert.h>
void doIt(char* string)
{
string[0]++;
}
int main()
{
char string[256] = "foo";
assert(strcmp(string, "foo") == 0);
doIt(string);
assert(strcmp(string, "goo") == 0);
}
--
Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-06-19 09:56 +0200 |
| Message-ID | <XnsA3516518CBF33eejj99@194.109.133.133> |
| In reply to | #24935 |
Christoph Michael Becker <cmbecker69@arcor.de> wrote on 19 jun 2014 in comp.lang.javascript: >> A function can never change a string in any programming >> language, because a string is a value, just as a number. When you see a string as a named value, you can change that value, if you don't mind it is stored somewhere else every time. Only Javascript offers no direct method to do that, well, discounting the string operator +=, the method concat(), etc. Unnamed string values inside methods, like regex methods, could be handled and stored quite differently inside the engine. > I beg to differ. Consider C: I too beg to differ. Concider original Forth, where each string is stored as a length value plus the the allotted number of bytes or words. You can find the memory address of say the third character and change that. But that is all semantics depending on the definition of "string". -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2014-06-18 16:12 -0700 |
| Message-ID | <6dcf9ddc-05f3-496c-a11d-624a75213cdc@googlegroups.com> |
| In reply to | #24909 |
On Wednesday, June 18, 2014 2:39:21 PM UTC-5, jonas.t...@gmail.com wrote: > Can i change value of a substring or do i have to read the string into an Array? > > I want to change the value of substring a char in nstring. Is following possible? > > nstring="12345" > > n = nstring.length; > > val=nstring.substring(n-1,n); > > //Is it possible to subtract and add to the character in val? > val--; > > //Can you force a value in a string or must i read into an array > nstring.substring(n-1,n)=val; In JavaScript, a String is an immutable value and not a collection. You don't necessarily have to convert it into an array though to operate on it.
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.javascript
csiph-web