私はカスタムリストを逆にする関数を作りたいと思いますが、うまくいきません。前の質問で関数を提案しましたが、別の関数を使用しました。任意の外部関数、私はいくつかのコードを書いたと私はそれを動作させる方法のヒントをありがとうと思います。mylist標準の逆関数ml
datatype 'element mylist =
NIL
| CONS of 'element * 'element mylist;
fun reverse (CONS(x, NIL)) = CONS(NIL, x)
| reverse (CONS(x, xs)) = CONS((reverse xs), CONS(x, NIL));
私は取得していますエラーは次のとおりです。
stdIn:89.5-90.60 Error: right-hand-side of clause doesn't agree with function result type [circularity]
expression: 'Z mylist mylist mylist
result type: 'Z mylist mylist
in declaration:
reverse =
(fn CONS (<pat>,<pat>) => CONS (<exp>,<exp>)
| CONS (<pat>,<pat>) => CONS (<exp>,<exp>))
は、コードの何が問題になっているのですか?