For example, list = [1,2,3,4]. listProduct list returns [1,2,3,4,6,8,9,12,16] i.e [(1*1),(1*2),(1*3),(1*4),(2*3),(2*4),(3*3),(3*4),(4*4)]
I remember seeing that there was something that did this, but I can’t find that resource any more.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why does your example not include
2*2in the result?If it’s because it’s the same as
1*4— that is, you don’t want duplicates — thenOn the other hand, if you do want duplicates — if you want to multiply each number by each subsequent number in the list, and include duplicates in the result — then
You could use
triangularAutoZipWithin a more efficient version of the first solution: