我是SML的新手。我写了一个函数,它接受2个int和一个元组列表作为输入。 fun move(x,y,mylist:(int * int)list): NOxNO =
let
val counter = ref y-1
in
if y=1 then (x,y)
else (
while !counter > 0 do (
霍纳规则用于简化在特定变量值下评估多项式的过程。 https://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation#Standard_ML 我容易地应用于使用SML的方法中,到一个变量多项式,表示为int列表: fun horner coeffList x = foldr (fn (a, b) => a + b * x
我有以下两个“功能”:is_three和SOME fun is_three(number) =
case numbers of
3 => true
| _ => false
当我在下面的两个语句写我得到这个: is_three;
val it = fn : int -> bool
SOME;
val it = fn : 'a -> 'a option
我已经在SML中编写了下面的代码,但遇到了编译错误。 fun getTransIndex(t : TRANSACTION, (h::L) : TRANSLIST) : int =
let val i=0
in if (h=t) then i
else
if (getTransIndex(t,L)<>~1
then getTransIndex(
鉴于这些声明我有在SML无法理解流牵引件: exception Bad of string;
fun from seed next = Cons(seed,fn() => from (next seed) next);
fun head (Nil) = raise Bad("got nil in head")
| head (Cons(a,b)) = a;
fun tail (N
datatype 'a stream =
Nil
| Cons of 'a * (unit -> 'a stream);
exception Bad of string;
fun from seed next = Cons (seed, fn() => from (next seed) next);
fun head (Nil) = raise Bad "got n