Den torsdag 14 maj 2015 kl. 19:18:02 UTC+2 skrev jonas.t...@gmail.com:
> Den torsdag 14 maj 2015 kl. 17:12:33 UTC+2 skrev Ben Bacarisse:
> > jonas.thornvall@gmail.com writes:
> >
> > > I have this problem with feeding the function in correct order.
> >
> > The solution is the pass the arrays in the correct order to being with.
> > I posted about this the last time you asked:
> >
> > function doSomething(A, B) {
> > return lessThan(A, B) ? reallyDoIt(A, B) : reallyDoIt(B, A);
> > }
> >
> > > This function work great to swap the arrays as long they really are One and Two
> > >
> > > ->checkArrayOrder(One,Two) works fine and will swap the arrays if
> > > arrCompare return true.
> >
> > That's a terrible name. A function the determines some property should
> > be named for the condition it tests. If a function tests for an even
> > number, call it 'isEven', not 'checkParity'. Call a prime tester
> > 'prime' not 'check Divisors', etc.
> >
> > But here, the function both determines some condition and the acts on
> > that condition. It should be called 'swapIfLessThan' (or similar).
> >
> > > function checkArrayOrder(One,Two)
> > > {
> > > res = arrCompare(One, Two) //Here i check which one bigger smaller
> >
> > If you used a better name, the comment would be redundant, but even with
> > the comment I have no idea which way the test goes!
> >
> > <snip>
> > > ***But*** i want a more general function to swap any *GLOBAL* arrays?
> >
> > Stop wanting that! Manipulating global objects makes for terrible code.
> >
> > <snip>
> > --
> > Ben.
>
> Thank you Ben.
>
> When called from main it works fine like this.
>
> checkArrayOrder(arrOne,arrTwo);
>
> function checkArrayOrder(A, B) {
> return lessThan(A, B) ? resultmult = naiveMult(base, arrTwo, arrOne) : resultmult = naiveMult(base, arrOne, arrTwo);
> }
>
> In this case i have no trouble reach resultmult value.
>
> But when called from within my conversion function the resultmult returned is zero.
>
> resultmult is a global array, it is reset when i step into conversion.
> resultmult=[]
> and initialised
> resultmult[0]=1.
>
>
>
> But
Sorry it is not local that is problem, i forgot to pass length of arrays to multiplication.