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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:22:44+00:00 2026-05-21T07:22:44+00:00

l have a list following List = [[‘Dev’, ‘Jon’], [‘Dev’, ‘Darin’], [‘Dev’, ‘Hans’], [‘Test’,

  • 0

l have a list following

List = [['Dev', 'Jon'], ['Dev', 'Darin'], ['Dev', 'Hans'], 
['Test', 'Richard'], ['Test', 'Mike'], ['Test', 'Jon'], ['Test', 'Hans'], 
['Chef', 'Bozho'], ['Chef', 'Mike'], ['Chef', 'Jon']] .

I want to calculate how many times every person appear and add his time step by step
for example, the result is following:

[['Dev', 'Jon', 1], ['Dev', 'Darin',1], ['Dev', 'Hans', 1], 
['Test', 'Richard', 1], ['Test', 'Mike', 1], ['Test', 'Jon', 2], ['Test', 'Hans', 2], 
['Chef', 'Bozho', 1], ['Chef', 'Mike', 2], ['Chef', 'Jon', 3]]

thanks very much 🙂

  • 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-21T07:22:45+00:00Added an answer on May 21, 2026 at 7:22 am

    The solution could be something like this:

    count([], _, Zs, Zs).
    count([[X,Y]|T], Ys, Zs, Us) :- select([Y,C], Ys, Ys1), C1 is C+1, append(Zs, [[X,Y,C1]], Zs1), count(T, [[Y,C1]|Ys1], Zs1, Us), !.
    count([[X,Y]|T], Ys, Zs, Us) :- append(Zs, [[X,Y,1]], Zs1), count(T, [[Y,1]|Ys], Zs1, Us).
    
    
    transform(L1, L2) :- count(L1, [], [], L2).
    

    We use Ys list to store counters for all people and Zs list to accumulate every person with corresponding index. Hope it helps.

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

Sidebar

Related Questions

I have the following list Prelude> let a = [[1676,17348,10],[1677,18831,10],[1677,18896,10]] I want to convert
I have the following list [txtvers=1,userid=3A6524D4-E31C-491D-94DD-555883B1600A,name=Jarrod Roberson,version=2] I want to create a Dict where
I have the following list in Scala which I want to filter based on
I have the following list item that I want to append an 'Edit Settings'
I have the following list: alpha beta charlie delta I want to turn these
I have following list of arguments that I want to run some application with.
I have the following list of distinct strings: A B C If I want
I have following list of dictionaries: d = [ { 'name': 'test', 'regions': [{'country':
I have a list of 2d numpy arrays. As a test, consider the following
I have the following list of tuples: items = [ ('john jones', ['Director', 'Screenwriter',

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.