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

The Archive Base Latest Questions

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

Considering the following list : dalist = {{1, a, 1}, {2, s, 0}, {1,

  • 0

Considering the following list :

dalist = {{1, a, 1}, {2, s, 0}, {1, d, 0}, {2, f, 0}, {1, g, 1}}

enter image description here

I would like to count the number of times a certain value in the first column takes a certain value in column 3.

So in this example my desired output would be:

{{1,1,2},
{1,0,1},
{2,1,0},
{2,0,2}}

or :

enter image description here

Where the latest sublist {2,0,2} being read as: When the value is 2 in the first column, a corresponding value (same row in matrices world) in column 3 of 0 is present twice.

I hope this is not to confusing. I added the second Column to convey the fact that the columns are distant to each other.

If possible, no reordering should happen.

EDIT :

{1,2,3,4,5}

{1,0}

are the exact values taken by the columns I am actually dealing with in my data.

I know I am missing the correct description. Please edit if you can and know it. Thank you

  • 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-23T11:31:22+00:00Added an answer on May 23, 2026 at 11:31 am

    I tried to come up with something brand new using Sasha’s assumptions about the required output, but it got more similar to his code than I thought it would be. Still the differences are interesting enough to post.

       {#1, #2, Count[dalist[[All, {1, 3}]], {##}]} & @@@ 
        Tuples[
           {DeleteDuplicates@dalist[[All, 1]], 
            DeleteDuplicates@dalist[[All, 3]]}
        ]
    

    Edit
    With your clarification about the input the code can be simplified and actually improved to:

       {#1, #2, Count[dalist[[All, {1, 3}]], {##}]}& @@@Tuples[{Range[5],{0,1}}]
    

    The first version is correct only if at least one example of each possible outcome is actually present in each column.

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

Sidebar

Related Questions

Considering this article Developing a MVC component for Joomla , following is the code
Considering this part of a Java class, private List<Object> components = new ArrayList<Object>(); private
I have a nested list that looks like this: mylist = [['A;B', 'C'], ['D;E',
Considering the following List : answers = { {{1, 2}, {7, 3}}, {{1, 3},
Let's suppose I have a singly-linked list alike std::forward_list . I would like to
Considering the following function : template<typename... List> inline unsigned int myFunction(const List&... list) {
I have following code and would like to translate it to linq. Is it
Considering the following sample XAML file, which shows the first 1000 people of Facebook,
Considering following code public class A { public static void main(String[] args) { new
Considering the following TSQL: INSERT INTO Address(Street1, City, State, ZipCode) SELECT Street1, City, StateCode,

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.