C-style for loop in Common Lisp's Loop macro

(Posted on 2022-05-10)

I try to convert C-style for-loop in JS to Common Lisp's loop macro for a learning purpose.

for (i=0; i<10; i++) {
  console.log(i)
}

Above JS code can be converted to:

(loop with i = 0
      unless (< i 10) return nil
      do (print i)
      do (incf i))

And, of course, the version below is more appropriate.

(loop for i from 0 below 10 do
    (print i))

The first version looks more flexible in applying to another problem than the last one.