On Fri, Jan 03, 2003 at 02:30:01AM +0100, Martin Nilsson (bygger parser @ Pike (-) developers forum wrote:
You are probably on the right track. The problem description isn't a description but a title and a some Perl code. The most useful thing to do is what you have done, to interpret it in a context that makes sense for the language and make a useful example of how to solve an actual problem.
yup, very true, that i don't come up with these myself just shows my lack of experience, yet on with it:
Converting Between ASCII Characters and Values:
string char="foo"; int num = char[0]; // gets the ascii value from the first char (that's // what ord() in perl does) char = String.int2char(num);
char = sprintf("%c",num); // the same as String.int2char(num) :-) write("Number %d is character %c\n", num, num); Number 101 is character e
string str; array arr; arr = (array)str; str = (string)arr;
int ascii_value = 'e'; // now 101 string character = String.int2char(101); // now "e"
write("Number %d is character %c\n", 101, 101);
array ascii_character_numbers = (array)"sample"; write("%s\n", ascii_character_numbers*" ");
string word = (string)ascii_character_numbers; string word = (string)({ 115, 97, 109, 112, 108, 101 }); // same write(word+"\n"); sample
string hal ="HAL"; array ascii = (array)hal; for(int i=0; i<sizeof(ascii); i++) { ascii[i]++; }
string ibm = (string)ascii; write(ibm+"\n"); // prints "IBM"
pike7.4 debian woody build seems almost done... :-)
greetings, martin.