【发布时间】:2017-03-09 02:55:47
【问题描述】:
我希望完成的是将字符串和布尔值传递到列表中。 'switch' 运算符切换输入类型的前两个元素,'and' 运算符和前两个元素。
但是,如果我想“和”一个布尔值和一个字符串,我该如何向列表中添加一个错误字符串(“错误”)?此外,SMl 不接受 x::y::xs 我应该输入什么,因为无论类型如何,我都想切换。
datatype input = Bool_value of bool | String_Value of string | Exp_value of string
datatype bin_op = switch | and
fun helper(switch, x::y::xs) = y::x::stack
| helper(and, Bool_value(x)::Bool_value(y)::xs) = Bool_value(x and y)::xs
任何帮助将不胜感激,谢谢。
【问题讨论】: