符号是什么!在SML意味着什么?

时间:2014-03-19 20:21:08

标签: sml ml ref

SML中的符号是什么意思?

fun polysort(_,[]) = []
| polysort(_,[x]) = [x]!
| polysort(less,xs) =
 let
  val (ys, zs) = split xs
   in
   merge(less,polysort(less,ys), polysort(less, zs))
 end;

这会扭转它还是什么?我认为它与ref有关,但我也不明白。

1 个答案:

答案 0 :(得分:9)

通常,!是一个'a ref -> 'a函数,extracts the value from a reference cell。即:

val x  = ref 1;  (* create reference cell *)
val () = x := 2; (* update value in x *)
val y = ! x;      (* extract value from x *)

然而,在这种情况下,它看起来只是一个错字。