I'm not sure what you were expecting. It does return 0, but it does so after all the print statements are done. Remember, your "test" function just returns the input, so the map function just returns a list (well, a map object, but ...) and then we prod everything in the list. But that happens AFTER you have done the map on test, and that requires printing out all of them. The prod can't finish up until the entire list has been processed via map and the function "test". I could imagine an alternate implementation of prod which checked each time whether zero had been produced in an intermediate step, but that doesn't appear to be in the code in "prod??".
On Thursday, September 22, 2022 at 10:39:03 AM UTC-4 axio...@yahoo.de wrote: > sage: def test(n): > ....: print("n:", n) > ....: return n > ....: > sage: l = [2,3,5,0,7,11,17,19] > sage: prod(map(test, l)) > n: 2 > n: 3 > n: 5 > n: 0 > n: 7 > n: 11 > n: 17 > n: 19 > 0 > I expected that it would return 0 once we multiply with 0. > > Martin > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/9c864eb6-b8fd-42c4-b1e7-b7eef89deae0n%40googlegroups.com.