Rosetta Code "Cantor set"

7 views
Skip to first unread message

The Beez

unread,
Oct 6, 2025, 11:08:27 AM (5 days ago) Oct 6
to 4tH-compiler
Hi 4tH-ers!

Every now and then you'll find a surprise - and sometimes you do something surprising with it.

Lately, I wanted to add a few uBasic/4tH programs to Rosetta Code - and I came across the "Cantor set" article. But alas, all the structured BASIC variants offered only a version with a 81 by 5 array. And in uBasic/4tH we only have 256 elements for our array.

Now of course I could do something like a bit array - and that would have sufficed. I have done stuff like that. But after seeing the Forth version - that was out of the question.

It was a very nice program, requiring only a single string. And it wasn't too hard to port to 4tH, just two HIDEs and that's it.

So I devised an evil plan: port it to uBForth. Now uBForth is a bit different and I had to accommodate that, but it ran. I nicked some code from a ported ZX81 game and that was it.

As you might know, uBForth is converted to uBasic/4tH using a transpiler. So I took the transpiled code, formatted it and uploaded it to Rosetta code. Now, there is nothing wrong with the program. Just put it through the ubasic interpreter and it runs flawlessly. But it is very strange looking BASIC code, that's for sure!

Code in SVN.

Hans Bezemer

The Beez

unread,
Oct 8, 2025, 8:15:26 AM (3 days ago) Oct 8
to 4tH-compiler
BTW, you can find the code here. I've optimized it for native uBasic/4tH to a degree you can hardly mistake it for a Forth program. Also, I included the code.

Hans Bezemer
cantornv.bas
Reply all
Reply to author
Forward
0 new messages