Question: 6. Translate the following Lisp functions to ML. Note that is a function. Can the code be alternatively implemented using a loop in a
6. Translate the following Lisp functions to ML. Note that is a function. Can the code be alternatively implemented using a loop in a straightforward fashion? If yes, give the loop implementation as well. A) (define Count (lambda (fx) (cond ((cons? x) (if (f (car x)) (+ 1 (Count f (cdr x))) (Count f (cdr x)))) (else 0)))) B) (define Count (lambda (fx) (cond ((fx) 1) ((cons? x) (if (null? (cdr x)) (Count f (car x)) (else 0)))) (10 points) (+ (Count f (car x)) (Count f (cdr x))))) (10 points)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
