I think this thread already covers the issue pretty thoroughly.
s = string(s[1:2], A, s[4:end])
Note that using string as a variable name is not advised since it's a
function name.
On Mon, Oct 6, 2014 at 4:01 AM, JVaz joanvazquezmol...@gmail.com wrote:
Hello, I am new in Julia and it's the
Yeah :) I've never actually relied on that for anything important.
Indexing into strings is a either a slow or a dangerous way to live one's life.
-- John
On Oct 6, 2014, at 9:05 AM, Daniel Høegh dhoeg...@gmail.com wrote:
Would it not make sense to define replace for Int's and ranges like this?
replace(s::String, index::Int, r) = string(s[1:index-1]) *
I know it's slow but is it considered dangerous then please enlighten me. Can
it not be acceptable to some extend to sacrifice speed to simplicity, people
will do this trick or maybe worse things.
There is also MutableStrings.jl
at https://github.com/tanmaykm/MutableStrings.jl.
Hello colleagues,
this conversation is covering one of the most dangerous things that you can
do in SW engineering:
- How can i do X?
- This is not meant to be used. But i have a work around for you.
You can be absolutely sure that this will propagate and be the new default
way.
(I'm
We try to be helpful, and answer the questions as asked. We also provide
advice for improvements, if the question is likely to lead to a poor
program.
Julia gives you as a programmer lots of power, and if you don't follow
advice, you might end up in trouble.
If you change the internal
On Thu, Mar 20, 2014 at 10:59 PM, J Luis jmfl...@gmail.com wrote:
Well, ... thanks
But naive question though. If we can do it with elaborate tricks, why
not just have a clean simple way?
The bottom line for whether something should be mutable or not is
psychological: is the thing a value
Thanks to Ivar and Stefan for the great explanations. I think often we hear
don't do this, don't do that, but it's great to hear some good anecdotes
and reasoning. Also excited to see the improvements in Strings under the
hood.
-Jacob
On Fri, Mar 21, 2014 at 11:37 AM, Stefan Karpinski
I too want acknowledge all your work to explain why things work the way
they do. But I want also say that I did read the docs before asking. It
just happened that I missed that first part on the Strings that talk
about strings immutability and error message does not help much leading us
to the
On Friday, March 21, 2014 11:37:33 AM UTC-4, Stefan Karpinski wrote:
Getting back to your original example, I would counter that you never
really want to just do something like replace the 16th character of this
string in isolation. How did you figure out the index 16? What you really
Sure, there are always exceptions. In that particular case, you may want to
work with the data as mutable arrays of bytes, rather than as strings. Did
you want to replace the 16th byte or replace the *character* starting at
the 16th byte? What if that's a multibyte character? What if the 16th byte
On Fri, Mar 21, 2014 at 12:12 PM, J Luis jmfl...@gmail.com wrote:
I too want acknowledge all your work to explain why things work the way
they do. But I want also say that I did read the docs before asking. It
just happened that I missed that first part on the Strings that talk
about strings
Well, from this perspective, it makes sense why those strings should not
be mutable.
But from other perspectives, making strings immutable contradicts with
how natural languages are used. For instance, after I said I am a
professor, I want to say I am a scientist, or perhaps I change my
Le samedi 22 mars 2014 à 05:08 +0800, cnbiz850 a écrit :
Well, from this perspective, it makes sense why those strings should not
be mutable.
But from other perspectives, making strings immutable contradicts with
how natural languages are used. For instance, after I said I am a
Perhaps the right thing to do here then is to make replace accept a range
of characters to replace:
str = I am a scientist
replace(str,8:16,scholar)
?
On Fri, Mar 21, 2014 at 5:21 PM, Milan Bouchet-Valat nalimi...@club.frwrote:
Le samedi 22 mars 2014 à 05:08 +0800, cnbiz850 a écrit :
You're assuming that strings are specifically for holding sentences, which
is not the case. That's one possible use case, but certainly not the only
one. If you want to do this sort of thing, using a mutable array of words
seems much more appropriate anyway. You can easily wrap this in a Sentence
*The replace() function is pretty cool, but for this case all we need is
indexing and concatenation:*
*julia **s = I am a scientist.*
*I am a scientist.*
*julia **s = s[1:7] * scholar * s[end:end]*
*I am a scholar.*
It is a bad idea to modify internal data, even though it is allowed. If you
want a mutable string-like object, we have a IOBuffer() type which is
designed for building up strings.
On Thu, Mar 20, 2014 at 10:59 PM, J Luis jmfl...@gmail.com wrote:
Well, ... thanks
But naive question though. If
19 matches
Mail list logo