Author Topic: Lists Linking Demo  (Read 13441 times)

0 Members and 1 Guest are viewing this topic.

FellippeHeitor

  • Guest
Re: Lists Linking Demo
« Reply #15 on: January 19, 2019, 05:47:56 am »
What I probably didn't make clear when I first interacted with this thread is that I don't care what it's called.

Steve is in a funny (Clippy + [banned user]) mode in this thread and that's funny. That doesn't match you, man. Let it go.

(There comes a wall).

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Lists Linking Demo
« Reply #16 on: January 19, 2019, 11:33:18 am »
Here's may take one the link lists from this thread:

Pete --- Thinks like a Democrat

Steve --- Thinks like Clippy

I'm pretty sure happenings like this were mentioned in some chapter of some well read book somewhere. Oh yeah, Revelations, form The Bible.

Well, it's like they say... It doesn't matter if you call it a mountain lion or  cougar, if you argue over that while it's stalking you, all it knows is your names are lunch.

Pete

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Lists Linking Demo
« Reply #17 on: January 19, 2019, 01:50:56 pm »
I should apologize for my tone (I still might).

So first things first - my version of qb64.bas does not contain Idet$ for some reason. But that's irrelevant because a linked list is not just a string, either, so I can't imagine what point you make by directing me there. And the concept does not involve parallel tables or two arrays that need to point to each other. All of that is fluff, all of that misses the forest for the trees.

Let me try to fix things up here for our readers who didn't know...

An classical array is analogous to a pre-hollowed-out space in memory - a manifold if you like - into which you cram data. Even if you can change properties on the fly, such as the total number of elements, this is still a classical array. (Old news.) One assumption we make about storing data that way is the concept of "neighbors". On a rigid manifold, any given element has definite neighbors. You expect array member 4 to be sandwiched between members 3 and 5, so that when we loop through the elements, we hit 3, 4, 5 in order, all the way up to N or whatever. Again, all old news.

The classical array structure has plenty of problems, especially speed problems when the number of elements is large. To do any legwork in the array, we are often looping through the entire list of elements until landing on the right one - sortof like reading through the entire phonebook from the beginning until you find the entry you need... And god forbid you need to make an edit. For a classical array, we need to constantly bump existing elements to make room for the new elements. This is where naive text editors go wrong - if I want to make random edits near the top of a large file, the whole bulk of the text below needs to be jumping up and down the array at an amazing speed, and generates enough lag to kill the project, or to force wonky hacks. Even if computers *do* get fast enough to not notice the problems here, should we really be asking the machine to do all that extra work?

Proponents of linked lists say "no". To understand them is very simple. Throw away the idea of a classical array - the manifold - and thus the notion of "neighbors" goes out the window. There is no notion of jumbling data between bins anymore. To store one unit data in a linked list, you need (at bare minimum) three things:

1) The data itself, such as the letter "F", the number 7, or the whole encyclopedia (for the sake of argument).

2) An address to hold that data. This is just a unique integer that represents each element. Now check this out: In a classical array, these addresses go in linear order. The new idea is that in the linked list scheme, the linearity is not necessary. The data can occupy any unique address at all.

3) A pointing value holding the "next" element's address.

So one node in the list might be ("F",3,7), which stores the letter "F" at address 3, and then points to the next address at 7. This could mean there is some other node ("U",7,19) that stores the letter "U" at address 7, but then points out to 19, and so on. You can have more than one list in the same address space, you can have lists that intersect and merge like a half-zipped zipper or something... You may also violate linearity and create trees this way. Adding, removing, and rearranging elements becomes completely trivial with zero array shuffling.

So in conclusion, I'll admit, I didn't look closely at your code enough to decide if you're actually doing what I described here. If so, then congratulations, you may revert the thread title to what you had originally set.

You're not done when it works, you're done when it's right.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Lists Linking Demo
« Reply #18 on: January 19, 2019, 02:42:18 pm »
So first things first - my version of qb64.bas does not contain Idet$ for some reason. But that's irrelevant because a linked list is not just a string, either, so I can't imagine what point you make by directing me there. And the concept does not involve parallel tables or two arrays that need to point to each other. All of that is fluff, all of that misses the forest for the trees.

I more or less quit reading after this point, as you obviously have no clue of... pretty much anything.

idet$ is the variable where QB64 stores our code when we type it into the IDE.  It's found in numerous places inside the qb64 source, and if you can't locate it, you simply didn't bother to check the $INCLUDE files inside the source.

The way idet$ works is like this (from memory, feel free to check the source for specifics):

It stores a pointer for the length of a line + 8.
It stores the line.
It stores a pointer for the length of a line + 8.

So when reading this "list", the first pointer tells you how far to move to get to the data of the next line...

Now, see if that doesn't fill the definition of a "linked list" as you like to act oh-so-superior about:

Quote
In computer science, a Linked list is a linear collection of data elements, whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence. In its most basic form, each node contains: data, and a reference (in other words, a link) to the next node in the sequence.

a Linked list is a linear collection of data elements --- Check, it's all in one line of data in the string.

each element points to the next -- Yep.  It does that.

It is a data structure consisting of a collection of nodes which together represent a sequence.  -- Yep.  It's the sequence of lines that you enter into the IDE which makes up your code.

In its most basic form, each node contains: data, and a reference (in other words, a link) to the next node in the sequence. -- Yep, that's what it is.

But that's irrelevant because a linked list is not just a string, either, so I can't imagine what point you make by directing me there.

Maybe you need to do a little research to figure out what exactly you're trying to talk about, before you decide to proclaim someone else wrong on the issue.



Edit: Here, a little bit of the code from QB64 for you to consider:
Code: QB64: [Select]
  1. a$ = MKL$(l& + LEN(a$)) + a$ + idet$ + MKL$(l& + LEN(a$)) 'header, data & encapsulation (reverse navigatable list)

Gee, what does that look like?
« Last Edit: January 19, 2019, 02:48:17 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Lists Linking Demo
« Reply #19 on: January 19, 2019, 02:51:49 pm »
Would the nearest hack care to explain this screenshot then?

Is my QB64 version *that* old? The string ain't there bro. If so, then accuse me of being BASIC, haha.

Steve, listen to Fellippe - you need to let this whole thing go right after you concede the point, or go silent like you do on other threads where my argument lands against you. Don't accuse me of whatever hillbilly version of belittlement you detect, either. I'm being nothing but informative here.
Untitled.png
* Untitled.png (Filesize: 28.44 KB, Dimensions: 947x421, Views: 307)
You're not done when it works, you're done when it's right.

FellippeHeitor

  • Guest
Re: Lists Linking Demo
« Reply #20 on: January 19, 2019, 02:54:40 pm »
Idet$ is just a string you can find in ide_methods.bas. Not the exact definition of a linked list despite Steve advocating for it, but a clever hack Galleon came up to keep the whole loaded program in a structure other than an array (why? Beats me. But it works).

It differs from a linked list essentially because the elements are always in order.
« Last Edit: January 19, 2019, 02:56:26 pm by FellippeHeitor »

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Lists Linking Demo
« Reply #21 on: January 19, 2019, 02:58:32 pm »
Ah, thanks Fellippe. Sorry to imply you were a hack (but you DID answer first), haha...

But Steve would clearly contest your finding:
Quote
Go take a look in QB64.bas.  Idet$ is a basic linked list as you’re speaking of...

Wonder how he'll prove himself right *this* time...

You're not done when it works, you're done when it's right.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Lists Linking Demo
« Reply #22 on: January 19, 2019, 03:12:33 pm »
Idet$ is just a string you can find in ide_methods.bas. Not the exact definition of a linked list despite Steve advocating for it, but a clever hack Galleon came up to keep the whole loaded program in a structure other than an array (why? Beats me. But it works).

It differs from a linked list essentially because the elements are always in order.

It doesnt have to be, if Galleon would’ve updated the pointers...

Pointer of 100 + 8 ‘to move forward
100 characters of text
Pointer of 100 + 8 ‘to move backward
Pointer of 32 + 8 ‘to move forward
32 characters of text
Pointer of 32 + 8 ‘to move backwards


Now, say I want to add a line between the 100 characters and the 32...

Pointer of 132 + 24 ‘to move forward
100 characters of text
Pointer of 100 + 8 ‘backwards
Pointer of 32 + len(newline) + pointersizes
32 characters of text
Pointer of 8 ‘to move back, skip this pointer
Pointer of -40 ‘to move forward to next line
The new line of data
.....


The original was 1 points to 2...
The new is 1 points to the 3rd line entered, which then points to the second line entered...

Why Galleon chose to always keep idet$ in order is beyond me.  With the list structure, he didn’t have to do that.  As it is, I don’t see why a simple array wouldn’t have been more efficient...


https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Lists Linking Demo
« Reply #23 on: January 19, 2019, 03:13:56 pm »
Wonder how he'll prove himself right *this* time...

By simply *being* right.  :P
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Lists Linking Demo
« Reply #24 on: January 19, 2019, 03:17:40 pm »
Would the nearest hack care to explain this screenshot then?

Is my QB64 version *that* old? The string ain't there bro. If so, then accuse me of being BASIC, haha.

Bro, can you read??

Quote
idet$ is the variable where QB64 stores our code when we type it into the IDE.  It's found in numerous places inside the qb64 source, and if you can't locate it, you simply didn't bother to check the $INCLUDE files inside the source.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Lists Linking Demo
« Reply #25 on: January 19, 2019, 03:18:48 pm »
Sigh, so according to you:

qb64.bas = ide_methods.bas

... I'm glad I don't listen to you, man. Let's just drop this.
You're not done when it works, you're done when it's right.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Lists Linking Demo
« Reply #26 on: January 19, 2019, 03:21:37 pm »
Sigh, so according to you:

qb64.bas = ide_methods.bas

... I'm glad I don't listen to you, man. Let's just drop this.

Try to delete ide_methods and see what happens when you compile. QB64.bas.  It’s an integral part of the source...

Just because it’s inside an $INCLUDE doesn’t mean it’s not there...
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Lists Linking Demo
« Reply #27 on: January 19, 2019, 03:23:49 pm »
At this point I'm just playing with who gets the last word on this completely failed thread.
You're not done when it works, you're done when it's right.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Lists Linking Demo
« Reply #28 on: January 19, 2019, 03:28:54 pm »
At this point I'm just playing with who gets the last word on this completely failed thread.

Nice to see an internet troll admitting to their boorishness for a change.  Here, some advice for you:

Quote
...you need to let this whole thing go right after you concede the point, or go silent like you do on other threads where my argument lands against you. Don't accuse me of whatever hillbilly version of belittlement you detect, either. I'm being nothing but informative here.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Lists Linking Demo
« Reply #29 on: January 19, 2019, 03:40:44 pm »
Okay so let's recap.

You started this thread not knowing how to identify a linked list, and changed your mind on what to call this thread after several of us dropped hints.

Instead of conceding anything, you instead doubled down that you were right in the first place.

Then I throw down how it finally works, something a Wikidive could have told you.

You pretend not to read my explanation, and magically divine "aha, I can refer to an example of this that someone else made! (still not a real example)"

I'm not sure where your work enters this discussion.
« Last Edit: January 19, 2019, 03:42:55 pm by STxAxTIC »
You're not done when it works, you're done when it's right.