2
datatype term = node of string*term list
| vnode of string
J'ai une valeur de type terme. Comment puis-je l'imprimer en sml à la sortie standard.Impression sur la sortie standard dans sml
datatype term = node of string*term list
| vnode of string
J'ai une valeur de type terme. Comment puis-je l'imprimer en sml à la sortie standard.Impression sur la sortie standard dans sml
Vous devez d'abord créer une chaîne sur le term
, puis l'imprimer en utilisant print
. Pour transformer un term
en une chaîne, vous pouvez définir une fonction comme celle-ci:
fun termToString (node (str, terms)) =
"node("^str^", "^termListToString terms^")"
| termToString (vnode str) =
"vnode("^str^")"
and termListToString terms =
"["^String.concatWith ", " (map termToString terms)^"]"