Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute LISP Online

(defun triangle (a)
    (cond
        ((stringp a)
            (format t "strings are not valid input, please enter an integer")
        )
        ((not (numberp a))
            (format t "please enter an integer greater or equal to 1")
        )
        ((and (> a 0) (integerp a))
            (dotimes (row a)
                (print 1)
                (if (> a 1)
                    (dotimes (column row)
                        (write (+ column 2))
                        (format t " ")
                    )
                )
            )
        )
        ((and (< a 1) (integerp a))
            (format t "integers less than 1 are not valid input, please enter an integer greater or equal to 1")
        )
        ((numberp a) 
            (format t "decimal numbers are not valid input, please enter an integer")
        )
    )
)
(triangle 'a)

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.