Lisp randomize and using two functions to pull from list into another

后端 未结 2 1892
南旧
南旧 2021-01-23 12:29

Okay, so I am new to lisp and i have been working on this program for a couple days getting to know lisp and researching certain parts of lisp such as cons,cdr, let,funcall and

2条回答
  •  失恋的感觉
    2021-01-23 12:37

    Yes, you do have few argument in your call to cons here:

    (defun generate-candy-supply (size)
      (if ( = 0 size)
        (cons (nth( random (length candy-color)) candy-color))
        ;;    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <= HERE
        (generate-candy-supply ( - size 1))))
    

    cons needs two arguments, when you giving it just one. So with what are you cosing your color?

    Also indent your code properly, now it's really difficult to read.

提交回复
热议问题