Haskell , , . , . , length, . :
length :: [a] -> Int
, a ( ) Int. node , , , . Haskell , , Java, .
, (ADT). , String, Int, Int, String :
data StringIntPair = StringInt String Int
| IntString Int String
You can find out which of the two is taken by matching the samples by parameter. (Note that you only have one, as both the string and the string are encapsulated in ADT):
combine :: StringIntPair -> String
combine (StringInt str int) = str ++ show int
combine (IntString int str) = show int ++ str
source
share