Next: Term Tests and Manipulation, Previous: Builtin Introduction, Up: Built-Ins [Contents][Index]
Actions:
write_list(List)
Write the elements of
List. If the atomnl_appears inListit is written as a newline.You can also use
sp_(N)where N is a positive integer to insert N spaces. Strings inListare displayed without the string quotes ".." unless you write them withq_("..."). The quotes are then put around the string.
write_list : act(!list(@term))Example:
| ?? write_list(["List of atoms ",[a,b], nl_, "Set of nats ", {2,1,4,1}, nl_]). List of atoms [a, b] Set of nats {1, 2, 4}with the next output on the same line.
nl_causes a new line to be output as would the string"\n". In fact any of the C string control characters, such as"\t","\s"for tab and space respectively, can be put into a string and will have the intended effect unless the string is wrapped inside aq_term. So we could have written the above query as:| ?? write_list(["List of atoms ",[a,b], "\nSet of nats ", {2,1,4,1}, "\n"]).Other control term we can put in the list argument of
write_listare:
sp_(n), n positive integer. It will display n spaces.
uq_(Atom), whereAtomis an atom that normally needs to be quoted. It will be displayed without the single quotes.
q_(String), whereStringis string will be displayed with string quotes.
wr_(Var), will not displayVaras an underscore followed by a sequence of digits, as is normal, but will give it a name such asA,B,Cwhen displayed and will give subsequent occurence ofVarin the list to be output using the given name forVar.The following query illustrates the the use of
uq_andwr_.| ?? write_list([uq_('Hello')," there\n",wr_(_895),sp_(2), _895,sp_(2),wr_(_678),nl_]). Hello there A A B _895 = A : Ty1 _678 = B : Ty2 success
read_term(Term)
Matches
Termwith the next term denoted by the next sequence of characters typed at the terminal followed by fullstop, return.
read_term :act(??term)Example:
| ?? read_term(X). [a,b]. X = [a,b] : termNote that the variables in the term being read are new variables, unconnected to variables in the query.
| ?? read_term(A). [A]. A = [B] : list(Ty1) success
Also note that, for example, if the term being read is a compound term that has no type declaration then the query will raise an exception.
| ?? read_term(A). f(a). QuLog exception - exception term: input_term_type_error(read_term, "f(a)")
Next: Term Tests and Manipulation, Previous: Builtin Introduction, Up: Built-Ins [Contents][Index]