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有关,但我也不明白。
答案 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 *)
然而,在这种情况下,它看起来只是一个错字。