Jump to content
IGNORED

What if? Designing "Geneve 2020". Cool 3D views!


FarmerPotato

Recommended Posts

1 hour ago, FarmerPotato said:

@TheBF Thanks!  That's a nice binary tree. I should study other data structures in there. 

Ya it's pretty tidy.  For the life of me I have never been smart enough to know why I would need a binary tree for data. I guess the speed of searching is valuable? 

 

1 hour ago, FarmerPotato said:

 

For Word processing:  I'm not doing a general binary tree--no pointers. The one  feature from Heapsort is  the fixed-memory space, in place tree manipulation.


My "pointers" are just integers, and LEFT, RIGHT, UP are just integer math, since the tree is predictably laid out as 2^n cells per layer. To traverse does not require  recursion or a stack. It's like a mouse-in-the-maze right hand wall follower. 
 

. The node content is just a pointer into a block buffer. In operations, only pointers are swapped--to compact the tree or insert. 

OK so it's a doubly linked list I guess. 

I have been noodling that kind of thing too.  So you keep the text in block buffer "records" and the word processor goes through an array of links in RAM?

Are the strings in the block buffers held in fixed length records? 

 

 

1 hour ago, FarmerPotato said:

Box Diagrams Need General Binary Trees

 

In a different  algorithm, my hierarchy  diagram box and lines drawing code, I do use a general binary tree. (Here I also pass xt's --for the style to draw the box or line.)

In C, I implemented the drawing algorithm with two stacks, two while loops, no recursion. My Forth code for that is ugly and I can take hints from this nice tree implementation. 

In my box diagram drawing code, I use the names DLINK and RLINK instead of LEFT/RIGHT. Left links point down in the printout. Right go.. well, right! (Across the page.)
 

Here is a recursive line drawing function written by the late Dr. C. H. Ting that I have used for years.

Not the fastest but pretty small.  CODE word could speed up the 2ROT, 4DUP and the mid-point computation ( + 1+ 2/ ) 

 

DECIMAL 
: 2ROT ( d1 d2 d3 -- d2 d3 d1) S" 2>R 2SWAP 2R> 2SWAP" EVALUATE ;  IMMEDIATE 
: 4DUP  S" 4TH 4TH 4TH 4TH" EVALUATE ; IMMEDIATE 

: LINE ( x1 y1 x2 y2 -- )
\ ANS version of Dr. Ting's recursive line.  R.I.P.
    4DUP  ROT - ABS >R - ABS R>       \ compute dx dy 
    MAX 2 < IF  2DROP PLOT  EXIT THEN \ nothing do, get out  

    4DUP ROT 
    + 1+ 2/ >R    \ compute mid points 
    + 1+ 2/ R>           
    2DUP 2ROT RECURSE RECURSE ;

 

  • Like 2
Link to comment
Share on other sites

That's more sophisticated than my drawing!

 

: DRAWEDGE ( Len --)

  ASCII + EMIT

  2- 0 DO ASCII - EMIT LOOP

  ASCII + EMIT

;

 

+-------+   +-------+
| FORTH |---| STACK |
+-------+   +-------+


The data structure has right-links and down-links. A first pass assigns the boxes to columns and finds  the max width of each column. The second pass prints everything. 

Link to comment
Share on other sites

Ah. I completely misunderstood. 

That's an interesting approach. 

 

The DOS Forth I have, HsForth uses a data structure to hold the upper left corner x,y and the lower left corner x,y.

From that data it draws the box. It's overkill as is for TI-99 but the idea is interesting.

 

It might look like this in TI-FORTH 

: MAKE-WINDOW ( fg bg upperrow leftcol bottomrow rightcol  -- ) 
  <BUILDS  ,  ,  ,  ,  ,  ,
  DOES> ;  
    
  

 

You pass that data structure to >WB and it does all the magic of drawing the window with a border and setting EMIT, PAGE and key to work only in that window. 

There are other words to change the border characters from the default double line characters we saw in DOS. 

 

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...