1
我有一個元組列表[("hi", 1), ("yo", 2)];
,我想將這個列表'轉換'成使用sml中的標準輸出print s;
表格格式的表格。將元組列表打印到標準輸出'表'
例如上面的元組列表將產生一個輸出,如:
------------
| "hi" | 1 |
------------
etc...
------------
我有這樣的代碼,但它給我的錯誤:
fun outputTable [] = print "Nothing! \n"
| outputTable ((hd, n)::tl) =
print "-----------"
print "| "^hd^" | "^n^" |"
print "-----------"
outputTable tl;
以下是錯誤:
stdIn:15.2-17.21 Error: operator is not a function [tycon mismatch]
operator: unit
in expression:
(print "-----------") print
stdIn:15.2-17.21 Error: operator is not a function [tycon mismatch]
operator: string
in expression:
" |" outputTable
stdIn:13.5-17.21 Error: right-hand-side of clause doesn't agree with function result type [tycon mismatch]
expression: string
result type: unit
in declaration:
outputTable =
(fn nil =print "Nothing!"
| :: (<pat>,<pat>) =<exp^ <exp^ <exp<exp>)