Say, if I want to create a cartesian product of two lists, I could do (here in Haskell, but I can do the same e.g. in Scala or any other FP-able language)
cartesianProd = liftM2 (,)
then
>cartesianProd [1,2] [3,4]
>[(1,3),(1,4),(2,3),(2,4)]
Obviously, using (lifting) +
instead of tuple pairing, will produce list of sums of all combinations.
By FP definition, "lifting is a concept which allows you to transform a function into a corresponding function within another (usually more general) setting." The way I understand it, if I have monadic arguments, I can transform my binary function to work with them via liftM2. Where does the cartesian product comes from, though? Intuitively, I would expect [(1,3), (2,4)]
from the example above.