首页 文章

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

提问于
浏览
2

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 回答

  • 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 *)
    

    但是,在这种情况下,它看起来只是一个错字 .

相关问题