Can we have useful BASIC with no IF statements?

discussion of beeb/electron applications, languages, utils and educational s/w
User avatar
1024MAK
Posts: 6795
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Can we have useful BASIC with no IF statements?

Postby 1024MAK » Wed Sep 06, 2017 10:16 am

crj wrote:

Code: Select all

100 GOTO 130+20*(condition<>0)
110 PRINT "Condition-met clause"
120 GOTO 140
130 PRINT "ELSE clause"
140 PRINT "Continuing..."

(Not tested, but it ought to work, and is completely general.)

Needs changing to:

Code: Select all

100 GOTO (130+20*(condition<>0))
110 PRINT "Condition-met clause"
120 GOTO 140
130 PRINT "ELSE clause"
140 PRINT "Continuing..."

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
1024MAK
Posts: 6795
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Can we have useful BASIC with no IF statements?

Postby 1024MAK » Wed Sep 06, 2017 10:27 am

You can also do stuff like this:

Code: Select all

10 PRINT "Input a number"
20 INPUT A%
30 GOTO (A%*10+100)
100 PRINT "Zero" : END
110 PRINT "One" : END
120 PRINT "Two" : END
130 PRINT "Three" : END
140 PRINT "Four" : END
150 PRINT "Five" : END
160 PRINT "Six" : END
170 PRINT "Seven" : END
180 PRINT "Eight" : END
190 PRINT "Nine" : END
200 PRINT "Ten" : END

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

Commie_User
Posts: 916
Joined: Wed Jan 27, 2016 12:50 am

Re: Can we have useful BASIC with no IF statements?

Postby Commie_User » Thu Sep 07, 2017 3:29 pm

Yeah!

It makes me wonder just how many English language commands can be eliminated yet retain the exact same performance of any programs.

What's the guess?

crj
Posts: 328
Joined: Thu May 02, 2013 4:58 pm

Re: Can we have useful BASIC with no IF statements?

Postby crj » Thu Sep 07, 2017 4:23 pm

Are you aware of the concept of a Turing machine?

In computer science, it's generally regarded as the simplest possible model for a general purpose computer. You don't need much at all in order to be able to build everything!

Commie_User
Posts: 916
Joined: Wed Jan 27, 2016 12:50 am

Re: Can we have useful BASIC with no IF statements?

Postby Commie_User » Thu Sep 07, 2017 8:26 pm

crj wrote:Are you aware of the concept of a Turing machine?


Vaguely. But it's more my thrust just doing it BASIC-style.

crj
Posts: 328
Joined: Thu May 02, 2013 4:58 pm

Re: Can we have useful BASIC with no IF statements?

Postby crj » Fri Sep 08, 2017 1:50 am

You don't need to make a Turing machine; it's just a useful conceptual test: is something Turing-powerful?

You can eliminate as much of BBC BASIC as you like; provided it can still implement a Turing machine, it can still do everything it could before...

...just not necessarily efficiently.


Return to “software: other”

Who is online

Users browsing this forum: No registered users and 5 guests