I want to make function maptree with standard ML
问题 I want to make function maptree with standard ML. If function f(x) = x + 1; then maptree(f, NODE(NODE(LEAF 1,LEAF 2),LEAF 3)); should make result NODE(NODE(LEAF 2,LEAF 3),LEAF 4)) I write the code like below. datatype 'a tree = LEAF of 'a | NODE of 'a tree * 'a tree; fun f(x) = x + 1; fun maptree(f, NODE(X, Y)) = NODE(maptree(f, X), maptree(f, Y)) | maptree(f, LEAF(X)) = LEAF(f X); but when I execute this code like this maptree(f, (NODE(NODE(LEAF 1,LEAF 2),LEAF 3))); result is not I want to