Please write the map function and the reduce function for a  map-reduce task in TypeScript to calculate the total price of each cart. The data objects which are the input for the map tasks can be like both of the following examples. example 1:
```
{ firstname : "NAME_1",
lastname: "NAME_2",
adress: {...},
cart: { [ {prodid: 123, qty: 1}, {prodid: 456, 2} ]} }
```
example 2:
```
{ prodid: 456,
price: 34 }
```