Here's one way to display the even numbers from a sequence of 10 values in LISP:
(let ((numbers '(1 2 3 4 5 6 7 8 9 10)))
(dolist (num numbers)
(when (evenp num)
(print num))))
This code starts by defining a variable called numbers
and assigning it a list of integers from 1 to 10. Then, it uses the dolist
function to iterate over each element in the list. For each element, it checks if it's even using the evenp
function. If it is, it prints the number to the console using print
.
This code should output the even numbers:
2
4
6
8
10
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-05-06 11:00:00 +0000
Seen: 1 times
Last updated: Feb 10 '23
What is the method to generate a return statement in Common Lisp?
What is the method for enabling hs-minor-mode permanently in emacs?
How can the format specifier of emacs-lisp % be deactivated?
What is the AutoLISP code to create an alert that displays the value of a TEXT/MTEXT object?
Can you provide a LISP code that displays the even numbers from a list that has 10 values?