Using Tuples

Category:
Lists, Tuples and Options
Description: This sample shows simple uses of tuples
Code:
let TupleSample1() =
let data = 1,2,3
printfn "data = \n%A" data
let f (a,b,c) = (a+b,b+c,c+a)
let res = f(f(f(data)))
printfn "res = \n%A" res
let r1,r2,r3 = res
printfn "r1 = %d, r2 = %d, r3 = %d" r1 r2 r3
let r4,r5,r6 = f(res)
printfn "r4 = %d, r5 = %d, r6 = %d" r4 r5 r6

Execution Result:
data = 
(1, 2, 3)
res =
(17, 16, 15)
r1 = 17, r2 = 16, r3 = 15
r4 = 33, r5 = 31, r6 = 32

Last edited Sep 14, 2011 at 2:47 AM by ttliu2000, version 1

Comments

No comments yet.