Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27682

Re: Reverse elements in array, they can be integers or strings.

Newsgroups comp.lang.javascript
Date 2015-05-16 06:54 -0700
References (2 earlier) <fdb99a69-c853-4c3a-baca-b2de2d605a12@googlegroups.com> <87382wokfa.fsf@bsb.me.uk> <e39df594-b019-4f90-87d8-a60900547366@googlegroups.com> <87wq08n2mw.fsf@bsb.me.uk> <75516fa3-8c6c-49fe-a2e3-e603c4a598d8@googlegroups.com>
Message-ID <eb573bb3-c9ca-4267-812e-ae87358b9979@googlegroups.com> (permalink)
Subject Re: Reverse elements in array, they can be integers or strings.
From jonas.thornvall@gmail.com

Show all headers | View raw


Den lördag 16 maj 2015 kl. 15:37:53 UTC+2 skrev jonas.t...@gmail.com:
> Den lördag 16 maj 2015 kl. 14:11:27 UTC+2 skrev Ben Bacarisse:
> > jonas.thornvall@gmail.com writes:
> > 
> > > Den lördag 16 maj 2015 kl. 13:01:50 UTC+2 skrev Ben Bacarisse:
> > >> jonas.thornvall@gmail.com writes:
> > >> <snip>
> > >> > 21 should encode to [1,10] in base eleven because 11+10.
> > >> > But is stored in array as [01,1]
> > >> >
> > >> > Now i want a printout 1,10
> > >> 
> > >> You are still confusing numbers and their representations (or, maybe,
> > >> you now understand but have not found a way to write about the
> > >> distinction).  Either way, it makes it impossible to communicate about
> > >> numbers and their representations.  There is a simple solution:
> > >> console.log prints an unambiguous representation of a value.  You could
> > >> use that even if you don't fully understand the distinction it's making.
> > >> For example, this method will distinguish between a string "[01,1]", an
> > >> array of numbers [1,1], and an array of strings ["01","1"].
> > >> 
> > >> You seem to be asking how to turn [1,10] into "1,10" but that's too easy
> > >> to be the question.
> > <snip>
> > 
> > > No thar is not the question, i want to reverse the array and reverse
> > > the digits of *each element* within array on *decimal level*.
> > 
> > At some point you will start to take people's advice.  Until then I
> > don't think you will make much headway.
> > 
> > Show the output from console.log of the array you are starting with.
> > Then show the output from console.log of the "thing" you want.  I don't
> > even know if you want a string or an array, and if you want an array, I
> > don't know what type of elements it should have.  The output from
> > console.log will make it clear to other what task you are trying to
> > perform.
> > 
> > > I am doing arithmetic upon the elements so i know they are not stored
> > > as characters and strings.
> > 
> > OK.  (I note, however, that in one bit of code you once posted you
> > pointlessly converted them to strings only to immediately re-convert
> > them back to numbers.  This made me think that, at the time, you did not
> > know which you had in the array.)
> > 
> > > So i *assume* that the element stored at each index within array is an
> > > integer.
> > 
> > Since this is your program, you can know what it is.  There should be no
> > need to assume it.  This makes you statement "stored in array as [01,1]"
> > very odd.  That looks like an array of two integers, both of which are 1.
> > 
> > > Really how hard can it be to understand.
> > 
> > And how hard is it to do what I ask?  Show the console.log output for
> > the array you have and then do the same for the string you want to
> > print.
> > 
> > -- 
> > Ben.
> 
> I did get your point about using console.log() Ben and i appreciate it.
> That join should never been there in the first place. What i wanted to do was to make an integer of the array.
> 
> And one can for sure question my approach making even the counter a bignumb.
> An ordinary counter would be much faster, but would prevent bases bigger than
> 9007199254740992.
> 
> I do not want to lose speed with my simple naiveAdd() counter, but i also do not want to lose generality of approach, the idea is that it should work for anybase.
> 
> Thanks again for pointing out the usefullness of log.console.

Well in the end it will of course not be a counter multiplying exponents until the exponent multiple reached.

One must use a divide & conquour search setting min and max, closing in until the digit found.

A counter upto 9007199254740992 would be a long wait to find the right digit ;).
But i feel comfortable i will be able to use 1000 digit bases in the end.

Do arithmetic such as mult and div upon very big numbers.

And that is why i use my naive approach.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 02:03 -0700
  Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 02:10 -0700
    MAX_SAFE_INTEGER & MIN_SAFE_INTEGER, was Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 12:03 +0200
  Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 11:37 +0200
    Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 02:58 -0700
      Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 12:22 +0200
        Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 03:44 -0700
          Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 14:52 +0200
            Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 06:09 -0700
              Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 15:30 +0200
      Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 03:37 -0700
        Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 15:00 +0200
          Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 06:24 -0700
            Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 15:54 +0200
              Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 07:01 -0700
                Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 21:05 +0200
          Re: Reverse elements in array, they can be integers or strings. Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-16 23:07 +0000
            Re: Reverse elements in array, they can be integers or strings. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-17 00:28 +0100
              Re: Reverse elements in array, they can be integers or strings. Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-17 10:37 +0000
              Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-17 13:34 +0200
      Re: Reverse elements in array, they can be integers or strings. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-16 12:01 +0100
        Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 04:14 -0700
          Re: Reverse elements in array, they can be integers or strings. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-16 13:11 +0100
            Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 06:37 -0700
              Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 06:54 -0700
                Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 15:58 +0200
                Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 07:04 -0700
                Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 21:16 +0200
                Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 07:51 -0700
                Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 21:25 +0200
              Re: Reverse elements in array, they can be integers or strings. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-16 21:41 +0100
                Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-16 16:51 -0700
                Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-17 11:14 +0200
                Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-17 03:04 -0700
                Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-17 12:40 +0200
                Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-17 06:04 -0700
                Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-17 21:47 +0200
                Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-17 15:06 -0700
                Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-18 00:57 +0200
                Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-17 17:10 -0700
                Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-18 13:16 +0200
                Re: Reverse elements in array, they can be integers or strings. John Harris <niam@jghnorth.org.uk.invalid> - 2015-05-18 10:28 +0100
                Re: Reverse elements in array, they can be integers or strings. Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-18 16:44 +0000
                Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-18 10:16 -0700
                Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-18 10:13 -0700
                Re: Reverse elements in array, they can be integers or strings. John Harris <niam@jghnorth.org.uk.invalid> - 2015-05-18 19:42 +0100
                Re: Reverse elements in array, they can be integers or strings. jonas.thornvall@gmail.com - 2015-05-17 02:58 -0700
            Re: Reverse elements in array, they can be integers or strings. Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-16 22:41 +0000
          Re: Reverse elements in array, they can be integers or strings. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-16 15:11 +0200
      Re: Reverse elements in array, they can be integers or strings. John Harris <niam@jghnorth.org.uk.invalid> - 2015-05-17 11:27 +0100

csiph-web