dbTalk Databases Forums  

Re: Arrays of Arrays is useful, a hallmark of OO, and missing inMVBASIC

comp.databases.pick comp.databases.pick


Discuss Re: Arrays of Arrays is useful, a hallmark of OO, and missing inMVBASIC in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
frosty
 
Posts: n/a

Default Re: Arrays of Arrays is useful, a hallmark of OO, and missing in MVBASIC - 07-01-2006 , 04:21 PM






Quote:
Mike Preece wrote:

Well gee. If you compare code that works with 50,000 individually
addressable memory locations with one that works with a delimited
infinite-length string wouldn't you expect to see a wee difference?

SteveB wrote:
Sorry mate you totally missed the point. Someone suggested that I use
dynamic arrays. This was a response that they are useless by a factor
of more than 2000. What cant I use a dimensioned array you ask? Maybe
take the time to read the rest of the thread.
Does he not understand simple English?
Is he intellectually dishonest?!? =`8^o

--
frosty




Reply With Quote
  #12  
Old   
dawn
 
Posts: n/a

Default Re: Arrays of Arrays is useful, a hallmark of OO, and missing in MVBASIC - 07-01-2006 , 05:07 PM







frosty wrote:
Quote:
Homer L. Hazel wrote:
Steve,

Your code samples appear to be identical except for the word
Dynamic or Dimensioned at the top?

SteveB wrote:

Umm, yeah. Sorry. Here is the dynamic array version cut and pasted
from my test program.

YY='ABCDEFGHIJK'
NI=1000
NJ=50
ZZ=''
STARTTIME=SYSTEM(1020)
FOR II=1 TO NI
FOR JJ=1 TO NJ
ZZ<RND(NI)+1,RND(NJ)+1>=STR('X',RND(10))
NEXT JJ
NEXT II
STOPTIME=SYSTEM(1020)
PRINT (STOPTIME-STARTTIME) 'MD00':'ms'

Steve

Mike Preece wrote:
Well gee. If you compare code that works with 50,000 individually
addressable memory locations with one that works with a delimited
infinite-length string wouldn't you expect to see a wee difference?
I think you might be an idiot.

Ah, but is he self-aggrandizing? Or even vociferous? =`:^
Those of us who have been called Vociferous Ignoramous People
(http://www.dbdebunk.com/page/page/3161496.htm) perfer to go with the
simpler V.I.P. or possibly Database V.I.P. Thanks. --dawn ;-)



Reply With Quote
  #13  
Old   
Luke Webber
 
Posts: n/a

Default Re: Arrays of Arrays is useful, a hallmark of OO, and missing inMVBASIC - 07-02-2006 , 05:29 PM



SteveB wrote:
Quote:
Luke Webber wrote:

Quite apart from that little peccadillo <g>, I have other concerns about
the code. God knows we all love to carve up anybody who posts code in
this group (or is that just me?), but what is it with this bit?

Why dont you just comment on the dynamic array in this case being more
than 2000 times slower than a dimensioned array?.
OK, let's talk about that. You've taken a worst-case position here, and
I don't know whether that's deliberate or unintentional.

Quote:
I already explained the requirement in my earlier posts. You wont be
able to provide a solution because there isnt one in mvbasic. Ive been
programming non-stop in mvbasic since 1983.
If you've been coding in MV BASIC since 1983, you should be aware that
you can use a fixed array of dynamic arrays to result this sore of
problem. I modified your code to work with as follows...

YY='ABCDEFGHIJK'
NI=1000
NJ=50
DIM ZZ(NI)
MAT ZZ=''
STARTTIME=SYSTEM(12)
FOR II=1 TO NI
FOR JJ=1 TO NJ
ZZ(RND(NI)+1)<RND(NJ+1)> = STR('X',RND(10))
NEXT JJ
NEXT II
STOPTIME=SYSTEM(12)
PRINT (STOPTIME-STARTTIME):'ms'

(Note: Changed SYSTEM(1020) to SYSTEM(12) for D3)

That runs in 691ms as opposed to 500ms on my system. What's not to like?

Luke


Reply With Quote
  #14  
Old   
Luke Webber
 
Posts: n/a

Default Re: Arrays of Arrays is useful, a hallmark of OO, and missing inMVBASIC - 07-02-2006 , 06:43 PM



SteveB wrote:
Quote:
Luke Webber wrote:

If you've been coding in MV BASIC since 1983, you should be aware that
you can use a fixed array of dynamic arrays to result this sore of
problem.

Yes I have and yes I am thanks.
So... why did you show us the worst-case code? <g>

Quote:
What is not to like is that I need an unknown number of ZZ arrays to be
created during the processing but Pick has to predetermine the number
and sizes of all dimensioned arrays in advance ... unlike other
languages where you can happily create new arrays on the fly and store
them in other arrays at your convenience.
Well, not really. I thought that was probably going to be a point you'd
raise, so here is a little sample I prepared earlier, so to speak...

YY='ABCDEFGHIJK'
CURRENT.LIMIT = 100
NI=1000
NJ=50
DIM ARRAY(CURRENT.LIMIT)
MAT ARRAY=''
STARTTIME=SYSTEM(12)
FOR II=1 TO NI
FOR JJ=1 TO NJ
ARRAY.INDEX = RND(NI)+1
IF ARRAY.INDEX > CURRENT.LIMIT THEN
NEW.LIMIT = INT((ARRAY.INDEX/100) + 1) * 100
DIM ARRAY(NEW.LIMIT)
FOR ARRAY.POSN = CURRENT.LIMIT+1 TO NEW.LIMIT
ARRAY(ARRAY.POSN) = ''
NEXT ARRAY.POSN
CURRENT.LIMIT = NEW.LIMIT
END
ARRAY(ARRAY.INDEX)<RND(NJ+1)> = STR('X',RND(10))
NEXT JJ
NEXT II
STOPTIME=SYSTEM(12)
PRINT (STOPTIME-STARTTIME):'ms'

Quote:
The best possible solution in Pick has already been highlighted in the
thread. Just write everything into hashed files instead of dimensioned
or dynamic arrays. Since the files are cached in memory they
approximate hashed collections in other languages. This solution is
fast enough even though I find it about 15 times slower than accessing
numerical arrays.
The above ran in a little less then twice the time taken for the
pre-dimensioned example (on D3), and I think it's considerably simpler.
This despite Peter's obvious distaste for redim.

Luke


Reply With Quote
  #15  
Old   
Luke Webber
 
Posts: n/a

Default Re: Arrays of Arrays is useful, a hallmark of OO, and missing inMVBASIC - 07-02-2006 , 07:54 PM



SteveB wrote:
Quote:
Luke Webber wrote:

So... why did you show us the worst-case code? <g

To show that dynamic arrays werent a solution to the problem at hand
...
But, to a certain extent at least, they are. It just seems a little
dishonest to me to deliberately show them in the worst possible light.

Quote:
Well, not really. I thought that was probably going to be a point you'd
raise, so here is a little sample I prepared earlier, so to speak...

Yes redim *is* a way to dynamically acquire dimensioned memory during
processing. It is still rather clunky to use in more complicated
scenarios but works to a degree when you are desperate. I still miss
proper memory acquisition techniques available in all the other
languages that I use.
Well I should think so. I happen to agree that MV BASIC is showing its
years, and has lost considerable ground to (*ahem*) more /actively
developed/ languages and libraries. <g>

Cheers,
Luke


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.