Search found 2 matches
- Tue Sep 04, 2018 11:45 am
- Forum: Homework
- Topic: Product function
- Replies: 2
- Views: 27481
Re: Product function
Thanks. I got it with recursion. Here's what I was able to figure out: (defun product (x) "This function takes in an arbitrary parameter x, and returns the product of all numeric values contained within x." (cond ((consp x) (* (product (car x)) (product (cdr x)))) ((numberp x) (* x 1)) (t ...
- Sat Sep 01, 2018 7:12 pm
- Forum: Homework
- Topic: Product function
- Replies: 2
- Views: 27481
Product function
I'm very new to Lisp. I'm trying to make a product function that takes in an arbitrary parameter x. The function should return the product of all numeric values contained within x. For example, > (product ’x) 1 > (product ’(x 5)) 5 > (product ’((2 2) 3) ) 12 > (product ’((a 3) (2 1)) ) 6 I'v...