逻辑: eploy(列表,常数) if list is empty then
return:
0;
else
return:
(first_element + constant*eploy(rest_of_the_elements, constant)
我已经写了下面的代码: fun eploy(xs, x1:int) =
if nul
我想在SML中编写一个函数,它搜索字符串的元组列表,并且如果它在元组的第一个元素中找到字符串,则返回第二个元素。 fun getFromBlist (name : command, (x,y)::tail : (command*command) list) =
if x = name then y else getFromBlist(name, tail)
| getFromB
我编写了这个函数来确定给定元素是否存储在元组列表的列表中,但是此刻它只搜索第一个列表。我将如何去搜索其他列表? fun findItem (name : command, ((x,y)::firstlist)::tail : (command*command) list list) =
if x = name then true else findItem(name, firstlist
我正在写一个仿函数来实现标准ML中的集合。由于集合不允许重复,我不希望它被限制在平等类型,它的声明如下: signature SET = sig
type t
type 'a set
val add : t -> t set -> t set
...
end
functor ListSet (EQ : sig type t val equal : t
我实现套标ML。目前,它看起来像这样: signature SET = sig
type t
type 'a set
...
val map : ('a -> t) -> 'a set -> t set
end
functor ListSetFn (EQ : sig type t val equal : t * t -> bool end)