在 SML 中返回两个变量

Returning two variables in SML

我下面有一个使用变量 X 和变量 A 的函数。

我如何return这两个变量才能在程序中进一步使用这些值。

val a = 1000;
val x = 5;

fun test (x,a) =
    if (a<1) then(
    x)

    else( 
    test(x+1,a-1)
    )

你刚刚return一对:

fun test (x, a) = if a < 1 then (x, a) else test (x+1, a-1)

您通过模式匹配收到它:

val (y, z) = test (10, 11)