MSX Basic Question

Página 2/2
1 |

Por kanima

Master (194)

imagem de kanima

24-06-2017, 01:47

Even slightly shorter:

10 A$="manuel-san wa ichiban ookii hito desu"
20 A=INSTR(A$," "):IFATHENA$=LEFT$(A$,A-1)+MID$(A$,A+1):GOTO20
30 PRINTA$

Or this version which is slightly longer, but uses a FOR/NEXT loop instead of a GOTO statement. This means it doesn't need its own line, which could be useful for 10-line BASIC contests etc:

10 A$="manuel-san wa ichiban ookii hito desu":FORA=1TO0STEP-1:A=INSTR(A$," "):A$=LEFT$(A$,A+(A>0))+MID$(A$,A+1):NEXT:PRINTA$

Por Manuel

Ascended (19330)

imagem de Manuel

24-06-2017, 09:19

I don't think I have anything to add here Smile So their strategy is to 'eat' the string.

Por Latok

msx guru (3929)

imagem de Latok

24-06-2017, 22:18

Thanks guys! And indeed, alter A$ is the way to go. Learnt something. Great!

Por Manuel

Ascended (19330)

imagem de Manuel

24-06-2017, 22:28

It's the way to go for the shortest implementation, but probably not for the fastest... The string is copied around a lot like this...

Página 2/2
1 |