The function read can be used to prompt the user and obtain a line of input as a string. In response to the prompt, the user enters sample and press return.
i1 : filename = read "file name : " |
Let's use peek to verify that this string contains no newline characters.
i2 : peek filename |
If necessary, we may use value to evaluate the string provided by the user. In this example, we enter (x+y)^2 in response to the prompt.
i3 : R = ZZ[x,y]; |
i4 : s = read "polynomial : " |
i5 : value s |