string quiz 1

In the string quiz 1 (jupyter notebooks), in the last question we are given a string:

i thought this would have been a list of 2 strings, using the type operator also returns 0h?  I also tried to combine the 2 parts into 1 string, and print to terminal, however I dont understand where I’m going wrong? sorry to ask 2 questions in one.

code:

str:(“wK<<<De<<< arB33e &:n”;“Ia<<< quSe<<<sGREATt!”) //is this not a list containing 2 strings
//str_w_string_opperator: string (“wK<<<De<<< arB33e &:n”;“Ia<<< quSe<<<sGREATt!”)
str_test : “test”;
show type str;
show type str_test

-1 "str 0: ", str 0;
-1 "str 1: ", str 1;

str_c : str 0, str 1;
show type str_c;
show str_c

 

 

There is an issue in your code due to left-of-right evaluation.

q)str_c : str 0, str 1; //This is the problem line q)str_c : (str 0), str 1; //Brackets help control execution order q)show type str_c; 10h q)show str_c “wK<<<De<<< arB33e &:nIa<<< quSe<<<sGREATt!”

 

If you break you statement down piece by piece you can see what it was doing:

q)str 1 //Index into position 1 of str “Ia<<< quSe<<<sGREATt!” q)0, str 1 // Append ‘str 1’ to the number 0 0 “I” “a” “<” … q)str 0, str 1 //Index in to str with a list (0;“I”;“a”;“<” … “wK<<<De<<< arB33e &:n” //Gets returned as first item in list is 0. Same as ‘str 0’ “” //Returns null character because ‘`int$“I”’ tries to index as ‘str 73’ “” “”

 

Thank you so much!