Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi! Can someone please help me figure out this (common) LISP programming question? So far, I have the following: (defun satisfy (fun lst) (fun lst)

Hi! Can someone please help me figure out this (common) LISP programming question?

image text in transcribed

So far, I have the following:

(defun satisfy (fun lst) "(fun lst) Returns a list of the items in a list that satisfy a function." (do ((numbers lst (cdr numbers)) (sat ())) ((null numbers) sat) (if (funcall #'fun (car numbers)) (cons (car numbers) sat))))

I tried to cons all the numbers that satisfy the function into the list "sat", but it's not working properly... I think it's an issue with the way I've used the funcall function. Can someone explain it to me?

Use do, if, and funcall to define (satisfy fun 1st) which returns a list of the items in a list that satisfy a function. An item satisfies a function if the function returns true when that item is used as the function's argument. Use do, if, and funcall to define (satisfy fun 1st) which returns a list of the items in a list that satisfy a function. An item satisfies a function if the function returns true when that item is used as the function's argument

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

Explain the process of MBO

Answered: 1 week ago