Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array in an array
#51
You folks have sure wandered far from the main subject problem of OP.

Associative arrays really aren't a solution to arrays of arrays but are an interesting topic on their own.
TempodBasic and I have kicked them around with a Rosetta Code Challenge on the old forum.
Too bad a new thread on that subject was not started.
b = b + ...
Reply
#52
(03-01-2023, 04:00 PM)bplus Wrote: You folks have sure wandered far from the main subject problem of OP.

Associative arrays really aren't a solution to arrays of arrays but are an interesting topic on their own.
TempodBasic and I have kicked them around with a Rosetta Code Challenge on the old forum.
Too bad a new thread on that subject was not started.

I agree that associative arrays on their own are not a solution. 
If you see my original reply in this thread, what I suggested wasn't an associative array, but a data structure similar to objects in JavaScript - and not OO, with methods / classes / etc., but just a data structure allowing nested arrays, dictionaries & objects, and functions for serializing/deserializing to & from JSON (which would solve the issue of persistence, since reading/writing JSON as text is trivial).
Reply
#53
------
Reply
#54
Not much different from handling associative arrays the "traditional" way.

However it's possible now with the _MEM gang. Copy that old source code from Turbo Pascal, however in QB64(PE) the pointer is always neutral. I don't know if the _MEMGET and _MEMPUT syntax works with UDT "as <type>" being the final parameter.

Might be able to arrange it coding in C++, and write subprograms in QB64(PE) to make a request to add an element, to count the number of list elements, to change the reference of one of the members, and so forth. The trade-off is that the programmer might have to hard-code the UDT to make it simpler.
Reply
#55
(03-02-2023, 08:34 AM)Sprezzo Wrote: Now that this thread is 6 pages long, here comes a bucket of saltwater: Linked Lists

Look them up anywhere but here.

Easy to bitch not so easy to teach.

So why not try showing us what you mean? I suggest another thread.
b = b + ...
Reply
#56
I have no problem with MEM being used but in my opinion it should always be used with MEMGET instead of some weird algorithm for accessing the data within. To my knowledge, MEMGET does work with UDTs. You just can't have any variable-length strings in the UDT or else it won't work right.
Tread on those who tread on you

Reply
#57
(03-02-2023, 05:19 PM)Balderdash Wrote: I have no problem with MEM being used but in my opinion it should always be used with MEMGET instead of some weird algorithm for accessing the data within. To my knowledge, MEMGET does work with UDTs. You just can't have any variable-length strings in the UDT or else it won't work right.

Variable length strings do work in UDT, you just can't file them in a records format.

I am not sure if MEMGET or Memory techniques can work with variable length strings inside or outside of a UDT.
b = b + ...
Reply
#58
@bplus
Yeah, variable length strings work in UDTs. I was talking about MEMGET on a UDT that has variable length strings.
Tread on those who tread on you

Reply
#59
Ah! thanks for clearing that up Smile
b = b + ...
Reply
#60
In terms of an Array in an Array, if the index could work with decimal values, theoretically you could create an array of multiple layers making say the whole numbers the name of the student and decimal values could associate with that student. For example all .5 could carry attendance, all .9 carry math test score etc. The expansion could be limitless. But it doesn't work. Here is my attempt 

Code: (Select All)
Dim Shared TestArray(1.1 To 2)

For x = 1 To 2 Step .1
    TestArray(x) = x
Next

For x = 1.1 To 2: Print TestArray(x);: Next
Print
Print TestArray(1.1)
Print TestArray(1.2)
Print TestArray(1.3)
Print TestArray(1.4)
Print TestArray(1.5)
Print TestArray(1.6)
Print TestArray(1.7)
Print TestArray(1.8)
Print TestArray(1.9)
Print TestArray(2)

The results provide only 1.4 or 1.9. Why I don't know.
Reply




Users browsing this thread: 9 Guest(s)