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 inList
it is written as a newline.You can also use
sp_(N)
where N is a positive integer to insert N spaces. Strings inList
are 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_list
are:
sp_(n)
, n positive integer. It will display n spaces.
uq_(Atom)
, whereAtom
is an atom that normally needs to be quoted. It will be displayed without the single quotes.
q_(String)
, whereString
is string will be displayed with string quotes.
wr_(Var)
, will not displayVar
as an underscore followed by a sequence of digits, as is normal, but will give it a name such asA
,B
,C
when displayed and will give subsequent occurence ofVar
in 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
Term
with 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]