id

Code Snippets đŸŒ±

Posted:
Table of contents:

Common Lisp

Read Number To List In Common Lisp

This code is mostly used in online programming judges.

(defun read-list ()
  (let ((n (read *standard-input* nil)))
    (if (null n)
        nil
        (cons n (read-list)))))
CL-USER> (read-list)
1 2 3 4 nil ; stop after accepts `nil`
(1 2 3 4)
CS

Continue Reading:

So what do you think? Leave your comments below.