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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:29:01+00:00 2026-05-22T03:29:01+00:00

I have: ListOne = [‘foo’, ‘bar’, ..] I now want to create a new

  • 0

I have:

ListOne = ['foo', 'bar', ..]

I now want to create a new List by zipping ListOne with ListTwo. ListTwo looks like this:

ListTwo = [{count, 1},{count, 1},{count,1}, ..] 

What’s a nice way to dynamically generate ListTwo? Every list item will be the same.

I want to feed the result of the zip to dict:from_list. So maybe a zip is not the best approach.

  • 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-22T03:29:02+00:00Added an answer on May 22, 2026 at 3:29 am

    While your question could be more specific, my guess is that you want to use a dictionary to store key, value pairs where the value is a counter. What you are trying to achieve by asking this, is how to initialize the dict with the counter set to 1.

    The folloing code will create a new dict, where the key is the key from ListOne and the value is 1:

    ListOne = [foo, bar, baz, quux].
    D1 = dict:from_list([{Elem, 1} || Elem <- ListOne]).
    

    Now, to increment these counters, you can use dict:update_counter/3:

    D2 = dict:update_counter(foo, 1, D1).
    

    To decrement, you would simply give a negative number as the increment.

    It is also worth noting that dict:update_counter/3, will create the key in the dict if it is not already present, with the given increment as the initial value.

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

Sidebar

Related Questions

I have three lists of User : ICollection<User> listOne = _somewhere.GetUsers(1); ICollection<User> listTwo =
Suppose I have a class like this: public class ThingManager { List<SomeClass> ItemList; public
I have a list of strings List<string> lstOne = new List<string>() { January:1, February,
Say I have a list and a vector, and I want to zip them
I have 2 list containing dictionaries as follows: listone = [{'unit1': {'test1': 10}}, {'unit1':
var listOne = new string[] { dog, cat, car, apple}; var listTwo = new
I have a list items as below and i want to hide the children
I have two ul's (.listone and .listtwo respectfully) floated left and the other right.
I am working on a library type database. Supposed I want to create 2
I have 3 ListView's that are populated like this (well this can be anything,

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.