Python Forum
Sequence Generator - Long number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sequence Generator - Long number
#1
Hello,

Any way i can redo same Java code to Python.

Usecase: Sequence Generator - if i give as LongSequence('s1',1100110000000001,1) - should return 1100110000000002

	private static final java.util.Map<String, Long> seq_Hash = new java.util.HashMap<String, Long>();
    public static Long LongSequence(String seqName, Long startValue, int step) {
      if (seq_Hash.containsKey(seqName)) {
          seq_Hash.put(seqName, seq_Hash.get(seqName) + step);
                if(seq_Hash.get(seqName)>9999999999999999L){
                      seq_Hash.put(seqName, 0L);
                }
          return seq_Hash.get(seqName);
      } else {
          seq_Hash.put(seqName, startValue);
          return startValue;
      }
  }
Thanks
Reply
#2
This forum is focused more on education than writing others' code for them. If you give it a try yourself, we'd be happy to help with any issues you run into.
Reply
#3
Also, why do you want to translate this?
Reply
#4
In addition, if you explain in plain english what your goal is you will have a better chance on getting help. Not everyone is familiar with JAVA...
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  float("{:.2f}" return long number? korenron 2 1,025 Jul-13-2022, 05:35 AM
Last Post: korenron
  print two different sequence number mantonegro 2 1,651 Nov-16-2020, 06:19 PM
Last Post: mantonegro
  Random number generator charlottelol 5 3,196 Nov-10-2020, 10:51 PM
Last Post: deanhystad
  basic random number generator in replace function krug123 2 2,029 Jul-31-2020, 01:02 PM
Last Post: deanhystad
  Help with a random number generator dpcalder 2 2,321 Jun-20-2020, 03:50 AM
Last Post: buran
  Factorial Code is not working when the given number is very long integer Raj_Kumar 2 2,287 Mar-31-2020, 06:40 PM
Last Post: deanhystad
  Repeating same number in sequence Rudinirudini 6 4,226 Oct-28-2018, 07:44 PM
Last Post: DeaD_EyE
  receive from a generator, send to a generator Skaperen 9 5,494 Feb-05-2018, 06:26 AM
Last Post: Skaperen
  help with a number sequence generator darktitan 2 3,240 Aug-27-2017, 03:19 AM
Last Post: darktitan
  splitting up long number iFunKtion 7 6,167 Dec-07-2016, 05:58 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020