sml

    1热度

    1回答

    如何将buf转换为sml/nj中的Word8VectorSlice.slice?例如, val msg = "hello\n"; val buf = Byte.stringToBytes msg; (* how to convert to Word8VectorSlice.slice ?*)

    1热度

    1回答

    逻辑: 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

    1热度

    1回答

    我想在SML中编写一个函数,它搜索字符串的元组列表,并且如果它在元组的第一个元素中找到字符串,则返回第二个元素。 fun getFromBlist (name : command, (x,y)::tail : (command*command) list) = if x = name then y else getFromBlist(name, tail) | getFromB

    2热度

    2回答

    我编写了这个函数来确定给定元素是否存储在元组列表的列表中,但是此刻它只搜索第一个列表。我将如何去搜索其他列表? fun findItem (name : command, ((x,y)::firstlist)::tail : (command*command) list list) = if x = name then true else findItem(name, firstlist

    0热度

    2回答

    我正在写一个仿函数来实现标准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

    1热度

    1回答

    我实现套标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)

    1热度

    1回答

    我写在SML插入排序一些代码。这里是。 fun compare(x:real, y:real, F) = F(x, y); fun isEqual(x:real, y:real) = ((x <= y) andalso (x >= y)); fun rinsert(x: real, L: real list, F) = [x] |rinsert(x, (y::ys), F) =

    0热度

    2回答

    林在SML使插入排序的代码,这是 fun compare(x:real, y:real, F) = F(x, y); fun isEqual(x:real, y:real) = ((x <= y) andalso (x >= y)); fun rinsert(x: real, [], F) = [x] |rinsert(x, (y::ys), F) = if isEqua

    1热度

    2回答

    因此,我目前正在学习考试,我一直在试图解决这个练习,但我真的不知道如何。 我需要实现一个函数,该函数将`a list和'a - > bool函数作为参数,并返回'a - 列表元素的数量,当给予'a - > bool函数时返回true作为参数。 到目前为止,这是我试过的代码: test([],funct) = [] |test(x::xs,funct) = if (funct(x) the

    1热度

    1回答

    我可以使用类型之前的类型和签名来专门化签名中的类型吗?这里有一个例子: signature A = sig type t type s end 我可以专注A通过以下? signature B = A where type s = t list SML/NJ和Mlton都抱怨t没有约束。