A language with string manipulation facilities uses the following operations
head(s): first character of a string tail(s): all but exclude the first character of a string
concat(s1, s2): s1s2
For the string "" what will be the output of
concat(head(s), head(tail(tail(s))))
View worked solution
Answer: C
Given the string and the operations defined as:
- : returns the first character of string .
- : returns the string excluding its first character.
- : concatenates and .
We evaluate the expression step-by-step from the inside out:
- Evaluate :
- Evaluate the inner :
- Evaluate the outer :
- Evaluate the head of the resulting tail:
- Perform the concatenation:
Thus, the output is , which corresponds to Option C.
Free practice · Your answers on this page are not saved.
