Skip to content

ex1 6

← Back

Basic Info

Functional Programming
└── Lab ML
    └── 0​321
        └── ex1 6.sml

Preview

(*Write a function sumPairs that takes a list of pairs of integers, and returns a pair of the sum of each component*)

fun sumPairs(nil) = (0,0)
| sumPairs((x,y)::zs) =
    let
        val (z1,z2) = sumPairs(zs)
    in
        (x+z1, y+z2)
    end
;