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 9101349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:06:27+00:00 2026-06-17T01:06:27+00:00

I want to write a small piece of test code to remind me that

  • 0

I want to write a small piece of test code to remind me that certain collections are equivalent i.e. simple, self-contained, easy to read and LINQ Lambda oriented (to fulfill a personal learning target).

Here’s what I have come up with:

var e = new IEnumerable<int> [] {
                                    Enumerable.Range(100, 4).ToArray(), 
                                    new int[] { 100, 101, 102, 103 },
                                    new [] { 100, 101, 102, 103 },
                                    Enumerable.Range(100, 4).ToList(), 
                                    new List<int> { 100, 101, 102, 103 }
                                };

var permutations = e.SelectMany(s => e, ( lhs, rhs ) => new { lhs,  rhs })
                    .Where( x => !x.lhs.Equals ( x.rhs ) ); 

foreach (var item in permutations)
{
    Assert.That( item.lhs, Is.EqualTo( item.rhs ) );
}
  • Q1. Is there a ‘simple’ alteration to yield 10 combinations of pairs (I currently have 20 permutations of pairs)? By ‘simple’ I mean using existing LINQ operators, rather than, say writing a recursive extension method.

  • Q2. Is there a better way of asserting “all members of the array are equivalent” in context?


As regards Q1, this would seem to give me the right-hand side (rhs) but how to I ‘carry-through’ (or rejoin to) the ‘original’ to give me the left-hand side (lhs)?:

var r = e.SelectMany(( e1, i ) => e.Skip( i + 1 ));
  • 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-06-17T01:06:29+00:00Added an answer on June 17, 2026 at 1:06 am

    This will work

    var leftHandSide = inputSequence.First();
    var rightHandSideList = inputSequence.Skip(1);
    
    rightHandSideList.All(s => s.SequenceEqual(leftHandSide));
    

    Basically we take 1st element, and compare remaining with this. Here I’m assuming order matters. Also assuming list has at least 2 elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so I'm trying to write a small piece of android code where I want
I want to write a small Android app with a GUI that should display
I am trying to write a small piece of Actionscript that gives focus to
I want to write a small tool, that does the following: When you right
I want to write a small program that given a time (in minutes) as
I'm trying to write a small piece of Javascript that will sort through a
Inspired by a recent TED talk , I want to write a small piece
I want to write a small app that sits in my tray and that
I want to write a small program in .NET 4.0 that will open a
I want to write a small program that should print something like testing CPU...

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.