[Gambas-user] multidimensional array of integers
Charlie Reinl
Karl.Reinl at ...9...
Tue Jan 15 19:47:58 CET 2008
Am Dienstag, den 15.01.2008, 17:01 +0100 schrieb ron:
> On Tuesday 15 January 2008 12:00, gaupe wrote:
> > Ron Thanks for pointing me in the right direction.
> > My mistake was apperently that i did not realise that it is not possible to
> > do this with a single statement.
> > if have some ancient experience with clipper5 an old database like language
> > and (i looked it up ;-)
> > it was as .... simple.. as
> >
> > 'asort( anArray,,,{|x,y| x[2] >= y[2] .AND. IIF( x[2] = y[2], x[1] <
> > y[1],.T.)})
>
> I asume this is clipper code, a friend of my did/still use it. :)
>
Ok, only one line of code.
But he forgot something, he is using a CodeBlock ,
{|x,y| x[2] >= y[2] .AND. IIF( x[2] = y[2], x[1] <> y[1],.T.)}
which will be compiled at run time.
So he's using code to sort.
> >
> > you would think that after all those years these simple things would be
> > functions classes or whatever
> > these are called, easy to use as these are the basics. same with dynamical
> > multidimensional arrays.
> >
>
> For most basic sort there is a command/method in many languages.
> Most of them are single dimension.
>
> For the double or more dimensions you should note that in every
> dimension the type of the cell can be nummeric or string based.
> This makes it more complex to write a general class for it.
> Once I did write for a module in VBA to manage this in a MS Access
> database where many sorts had to be done.
> This module was very big because all those variable types.
> Sorting numbers as value or as string need different ways.
>
> For usage you need to give the arrays but for every cell in those
> array the method to handle the cell before the sort.
>
> In PHP you can do such things with callbacks for the compare.
> Very powerfull.
>
> For your example code i see you did read and used the examples given.
>
>
> > btw the a.max does not seem to work also not a.max[0] or a[0].max
> > so i used a.bounds[0] for that
>
>
> Regarding the gambas help the UBound(arrMyArray) should be
> arrMyArray.Max. If that isn't the case then maybe a bug or
> it is replaced by arrMyArray.Bounds. Not clear to me.
> I expect the .Bounds is an array where .Bounds[0] is the lower
> index as LBound() and .Bounds[1] same as UBound().
>
> Maybe Benoit can explain.
>
> Ron
--
Amicalment
Charlie
More information about the User
mailing list