Re: Use strings in Mathematica, like in C?
- To: mathgroup at smc.vnet.net
- Subject: [mg61412] Re: Use strings in Mathematica, like in C?
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Tue, 18 Oct 2005 02:45:10 -0400 (EDT)
- Organization: Uni Leipzig
- References: <disllm$mj5$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, Unprotect[Set]; Set[Part[s_Symbol, i_Integer], rep_String] := Module[{ch}, ch = Characters[s]; ch[[i]] = rep; s = StringJoin @@ ch] /; Head[s] === String Protect[Set] message = "Hello"; message[[2]] = "bo" "Hbollo" Regards Jens "Renan" <renan.birck at gmail.com> schrieb im Newsbeitrag news:disllm$mj5$1 at smc.vnet.net... | Hello, | | In the C programming language I can operate directly over the | characters of a string, like: | | int main() { | | char message[16] = "Hello!"; | message[n]='a'; | | /* ... other code ... */ | return(0); | | } | | This mean: Change the (n+1)th character (in C, array starts at 0) to the | specified character. | | Q: How can I obtain similar effect in Mathematica? | | Thanks! | -- | Thanks/obrigado, Renan "Wishmaster" Birck - Canoas, Rio Grande do Sul, Brasil | MSN: wizard_of_yendor at hotmail.com | Orkut: http://www.orkut.com/Profile.aspx?uid=2202360379963855296 |