str = "abcabc"
arr = convert(Vector{UInt8}, str)

# you can increase indeces with addition now.
arr[1] += 5

# convert back
str2 = convert(typeof(str), arr)
println(str2) # -> should print "fbcabc"


On Wednesday, August 24, 2016 at 7:35:58 AM UTC-7, Rishabh Raghunath wrote:
>
> *Hello Julia Users !!..*
>
> I have asked this question before in the forum but am still a bit unclear 
> on how to do the below.. I have condensed a few of my doubts in the 
> question below.
>
> Being from a C background where strings are just character Arrays, 
> manipulating individual characters using the array index was easy.. However 
> In julia that definitely does not seem to be the recommended way to go 
> about doing things and I have a lot of doubts about the small details on 
> the language. Here's a small example of what I am trying to achieve with my 
> program .. This is a fairly simple program while doing it in C but I have 
> absolutely no idea how to implement the same in Julia as strings cannot be 
> treated like character arrays and i cannot just  increment an index of the 
> string to increase the ASCII value of the character in Julia. Please try to 
> solve the problem or guide me on how to implement this in Julia.. I promise 
> the question is very simple and isn't as complex as It may seem at a 
> glance. 
>
> *My Aim*:
>
>         To write a program a program which accepts a string via the input 
> and encrypts it to the following simple algorithm ..
>
> *Algorithm:*
>
> *Example Input String:     abcabc*
>
> 1. Increase the ASCII value of the character at the *ODD index* of the 
> string  by 5 steps( example increased the ASCII value of '  *a*  ' by 2 
> thus making it   ' * c*  '  
> 2. Increase the ASCII value of the character at the *EVEN index* of the 
> string  by 1 step( example increased the ASCII value of ' * b*  ' by 1 
> thus making it   '  *c*  '
> 3. Print the new encrypted string on Screen. I need it stored in a new 
> string variable say z *(OUTPUT : ccebdd  )*
> 3. Insert a ' - ' between each pair of characters of the string and store 
> in new string in another string variable say y.
> 4. Print string y on the screen  * (OUTPUT : cc-eb-dd  ) *
> 5. Change all the characters in the string into its number equivalent. ( 
> a=1,b=2,c=3,.....) and separate the numbers representing each character by 
>  '  :  ' 
> 6. Store the new string from the above operation in variable v and print v 
>  *(OUTPUT : 3:3-5:2-4:4)*
>
> Guys .. Try to help me out !!.. I tried searching everywhere on the 
> internet for steps in doing the above operations in Julia but haven't found 
> anything.. I always get the index errors for treating Julia the C way.. 
> Please try to create a program that does the above.. Just so that Its 
> easier for me to understand what you are doing in the program rather than 
> type the directives in English and then later misunderstanding stuff... I 
> need to learn doing the above procedure the right way without messing with 
> stuff like using indexes in strings for character manipulation that may get 
> deprecated in the future..
>
> Thanks !! Waiting eagerly for a reply !!  
>
>

Reply via email to