Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7130051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:18:31+00:00 2026-05-28T11:18:31+00:00

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

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T11:18:32+00:00Added an answer on May 28, 2026 at 11:18 am

    Why does your example not include 2*2 in the result?

    If it’s because it’s the same as 1*4 — that is, you don’t want duplicates — then

    listProduct xs = nub [x * y | x <- xs, y <- xs]
    

    On 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

    listProduct' xs = triangularAutoZipWith (*)
    
    triangularAutoZipWith op = concatMap f . tails
      where f [] = []
            f xs @ (x : _) = map (op x) xs
    

    You could use triangularAutoZipWith in a more efficient version of the first solution:

    listProduct = nub . triangularAutoZipWith (*)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched, but found nothing to help.. This is an example: List.txt a b
Now this is example list : List<List<KeyValuePair<string, double>>> dblWordFreqByCluster = new List<List<KeyValuePair<string, double>>>(); What
I am looking at this example: List<Product> products = Product. GetSampleProducts() ; products.Sort( (first,
I'm reading the book 'Beginning F#', There's a short list for example code, to
I can't get icon in properManner, I use PackageManager : Code example ::List<PackageInfo> applications
How can I create a list of functions in JavaScript that preform actions together
is there a way to do a Console.WriteLine() on a Generic Collection example: List
I understand that in general a List is not thread safe, however is there
I have a question regarding sorting in C#. Lets assume that there is List<Person>
Example: list($fruit1, $fruit2) = array('apples', 'oranges'); code above of course works ok, but code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.