开发者

Standard ML Recursive Function

开发者 https://www.devze.com 2023-02-03 23:18 出处:网络
I am having trouble with recursion in sml. Basically, I have a function called xyz which takes in an int and a deck (a datatype which I defi开发者_开发技巧ned) and returns a hand(a datatype which I de

I am having trouble with recursion in sml. Basically, I have a function called xyz which takes in an int and a deck (a datatype which I defi开发者_开发技巧ned) and returns a hand(a datatype which I defined) and a deck (a datatype which I defined). The issue which I am having is that the function takes as input a int and a deck so how am I suppose to return two different data types (a hand and a deck).


I don't see how this has anything to do with recursion. Recursion is a function calling itself — you just talk about a function taking a pair of values and returning a pair of values of a different type. To return a hand and a deck, you'd just return a tuple (yourHand, yourDeck).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号