Recursive functions in BASIC

Lardo Boffin
Posts: 2256
Joined: Sat Nov 26, 2016 2:42 am

Re: Recursive functions in BASIC

Post by Lardo Boffin »

dr beep wrote: Thu Jul 18, 2024 9:55 pm
Lardo Boffin wrote: Thu Jul 18, 2024 9:20 pm I don’t have much call for recursion in my job (aside from occasional data validation of complex hierarchical structured data in TSQL) so mostly the DEF FN as shown.
I once had a query in a tool and it needed a recursive search to do the job,
An expert said it was not possible but I solved it. Problem was an IF was not possible but I solved it with boolean algebra and an empty string to return,
a bit like the DEF FN on the ZX Spectrum
A good programmer can write good code. A great programmer just assumes the task is possible and then tries to work out how.
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
TS 1000 iss 3, ZXPand AY and +, ZX8-CCB, ZX-KDLX & ChromaSCART
Tatung 81 + Wespi
TS 1500 & 2000
Spectrum 16k (iss 1 s/n 862)
Spectrum 48ks plus a DIVMMC future and SPECTRA
redgatemodels
Posts: 197
Joined: Tue Sep 05, 2023 11:56 am

Re: Recursive functions in BASIC

Post by redgatemodels »

Lardo Boffin wrote: Fri Jul 19, 2024 3:14 pm
dr beep wrote: Thu Jul 18, 2024 9:55 pm
Lardo Boffin wrote: Thu Jul 18, 2024 9:20 pm I don’t have much call for recursion in my job (aside from occasional data validation of complex hierarchical structured data in TSQL) so mostly the DEF FN as shown.
I once had a query in a tool and it needed a recursive search to do the job,
An expert said it was not possible but I solved it. Problem was an IF was not possible but I solved it with boolean algebra and an empty string to return,
a bit like the DEF FN on the ZX Spectrum
A good programmer can write good code. A great programmer just assumes the task is possible and then tries to work out how.
indeed, when I worked for a software house we had a well known architect client that had a very complicated drawing revision sequence. To complicate things they wanted to be able to load the drawings into the system in any order. Everyone said it was not possible to effectively re-order things every time a revision was loaded so that the actual latest version in their sequence was showing at the top, but one programmer wrote the most complex single nested SQL query that did just that. Don't think he ever got the recognition he deserved for that.

Maybe he should work for Viewpoint, as even now only the last revision uploaded is considered current ......
User avatar
stefano
Posts: 597
Joined: Tue Dec 11, 2012 9:24 am
Contact:

Re: Recursive functions in BASIC

Post by stefano »

Saomeone says that good programmers were those ones writing only readable and maintainable code.
They are SORT OF right, but sometimes a trick really makes the difference.

The numeric conversion trick is very cool, BTW !
Post Reply