Simply BASIC

I learned about programming on a Commodore 64 over twenty years ago. I still remember working through the BASIC programming examples in the user guide. So I thought it would be fun to start with Common Lisp this way and keep it simple.

When I first started learning BASIC, I thought loops were so cool. At that time, in some stores, they would have computers setup for display. Computers like the Commodore 64 and 128. I thought I was the coolest kid around because I could walk up to one of them and write a quick loop to print my name all the way down the screen over and over. (Hey, I was a kid, what can I say!)

So I decided to write a Common Lisp function that would print “Hello, World!” ten times down the screen. It looks like this.

(defun hello-world ()
    (dotimes (x 10)
        (format t “Hello, World!~%”)))

When this function is executed, the output looks like this.

Hello, World!
Hello, World!
Hello, World!
Hello, World!
Hello, World!
Hello, World!
Hello, World!
Hello, World!
Hello, World!
Hello, World!
NIL

You can consult some of the references I have mentioned in my previous posts to figure this out pretty easily. The format function can look visually strange I think. Especially when you see more advanced expressions. For instance, the ~% that follows Hello, World! inserts a new line, but it looks strange.

With all of this talk about BASIC and the Commodore 64, I decided to fire up my VICE C64 emulator and write the same program in BASIC. (Yeah, crazy, I know!) So here it is.

10 FOR X = 1 TO 10
20 PRINT “COMMODORE 64″
30 NEXT X

Then when you run this you get.

COMMODORE 64
COMMODORE 64
COMMODORE 64
COMMODORE 64
COMMODORE 64
COMMODORE 64
COMMODORE 64
COMMODORE 64
COMMODORE 64
COMMODORE 64

There you have it. I know it is simple, but it was a fun and easy way for me to achieve success with my first Common Lisp program.

No comments yet

Leave a reply