1

I am writing a function that is supposed to take in two values. The first value is supposed to create a list up to five numbers, based on the value entered. The second value is supposed to take the list and rotate it n times, based on the number entered.

Example of program interaction.

> (my_rotate_n 1,2)

> (3 4 5 1 2)

This is the function I currently have.

(defun my_rotate_n (y) (x)
    (append (loop for i from (+ 1 y) to (+ 4 y) collect i)
    (> x 0) (my_rotate_n (rotate-right y)(- x 1)))(list y))

When I test the function for an output I get the error: comma is illegal outside of backquotes Any suggestions?

sds
  • 58,617
  • 29
  • 161
  • 278
Keith Code
  • 57
  • 8
  • You can't use commas to separate arguments. Use a space. Looking at that function, you don't seem to be quite familiar with Lisp syntax. You should read some Lisp book (try the [Practical Common Lisp](http://www.gigamonkeys.com/book/) for example). – jkiiski Feb 11 '17 at 20:34

1 Answers1

4

Comma:

The comma is part of the backquote syntax; see Section 2.4.6 (Backquote). Comma is invalid if used other than inside the body of a backquote expression as described above.

To separate tokens, use Whitespace Characters.

IOW, instead of (my_rotate_n 1,2) you should write (my_rotate_n 1 2).

(This will not make your my_rotate_n work, of course, just avoid that particular error. You should invest some of your time in studying Lisp syntax.)

sds
  • 58,617
  • 29
  • 161
  • 278