### Using Funcall and function satisfiability

Posted:

**Sat Feb 02, 2019 12:57 pm**Could anyone help me solve this Common Lisp question?

Use do, if, and funcall to define (satisfy fun lst) 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.

This is how far I've gotten:

I'm assuming I haven't used funcall correctly but I have no idea what I'm doing wrong...

Use do, if, and funcall to define (satisfy fun lst) 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.

This is how far I've gotten:

- Code: Select all
`(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'm assuming I haven't used funcall correctly but I have no idea what I'm doing wrong...