Question: Evaluate using the following functions: ( defun g 1 ( h x ) ( if ( null x ) ' ( ) ( cons (

Evaluate using the following functions:
(defun g1(h x)(if (null x)'()(cons (funcall h (car x))(g1 h (cdr x))))) for simple list g1
(defun g1(h x)for nested list g1
(if (null x)
'()
(if (atom (car x))
(cons (funcall h (car x))(g1 h (cdr x)))
(cons (g1 h (car x))(g1 h (cdr x))))))
(defun f1(x)(* x x))
(defun f2(x)(* x x x))
(defun f3(x)(+ x 4))
(defun f (flist x)(if (null flist) x (f (cdr flist)(g1(car flist) x))))
3) Calling f with '(f1 f2 f3) and the well-formed-nested-list '((456)(123)(-1-23)) resulted in((41001562946660)(568733)(568733)). The invocation of f and the result are shown as follows:
LISP>(f '(f1 f2 f3)'((456)(123)(-1-23)))
((41001562946660)(568733)(568733))
The above is a successive application of f3 on the result of f2 on the result of f1, where f1, f2, and f3 are (defun f1(x)(* x x)),(defun f2(x)(* x x x)), and (defun f3(x)(+ x 4)).
Rewrite g1 and/or f so that the resulting list is a list of the results of applying f1 on the specified well-formed-nested-list followed by applying f2 on the specified well-formed-nested-list followed by applying f3 on the specified well-formed-nested-list. For example,
LISP>(f '(f1 f2 f3)'((456)(123)))
(((162536)(149))((64125216)(1827))((8910)(567)))
Source listing of function g1:
Source listing of function f:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!