# Taking one list Mod a second list

Just on my free trial and can't find this anywhere in online docs. Trying to use the Mod function as follows: Mod[{list},{list}} where it takes each number in list one mod each number in list two, but I get the error "Objects of unequal length in Mod cannot be combined." For instance, Mod[{55,76},{10,3,7}] yielding {5,1,6} for 55 and {6,1,6} for 76. Any way to do this?

• "Objects of unequal length in Mod cannot be combined." means what it says. Unless your two lists have the same dimensions, it doesn't work. Shorten one, or lengthen the other. Commented Feb 22, 2016 at 4:53
• Do you want the output would be in the form {Mod[list1[[1]], list2[[1]]], Mod[list1[[2]], list2[[2]]], ...} or {{Mod[list1[[1]], list2[[1]]], Mod[list1[[1]], list2[[2]]], ...}, {Mod[list1[[2]], list2[[1]]], Mod[list1[[2]], list2[[2]]], ...}, ... }? Please specify! If the latter is the case, C. Woods' answer would be appropriate. Commented Feb 22, 2016 at 5:07
• @JHM, I was under the impression that Mod was listable. In any case, it seems like his error was about "objects of unequal length" so seems like he was trying to do something like in the latter case. That's why I gave my answer about Outer. :) Commented Feb 22, 2016 at 5:13
• @JHM Sorry my question was unclear. I've edited it now. I think this fits your first example better, but I'm unsure. Commented Feb 22, 2016 at 6:58
• @user3363795 the answer by @C.Woods or Map[#,list2]&/@list1 Commented Feb 22, 2016 at 7:01

Yes, you can use the built in function Outer. It does exactly the kind of thing you are talking about it. Try
Outer[Mod, list1, list2]
Outer is a generalization of the outer product in Linear Algebra. Its first argument is a function, and the rest of its arguments are lists. Basically, it applies the function in the first argument to every element in the Cartesian product of the rest of the arguments. This is useful for doing things like you are trying to do: e.g. apply this function to every possible combination of these things.
• This would give all possible combination of Mods, wouldn't it? Commented Feb 22, 2016 at 5:03