Question: Satisfactory Create a function map-only-numbers that takes a mapping function and a list, and maps every element in a list that satisfies the predicate

Satisfactory Create a function map-only-numbers that takes a mapping function and a

Satisfactory Create a function map-only-numbers that takes a mapping function and a list, and maps every element in a list that satisfies the predicate number?. You are not allowed to use the map function for this. Here is an example run: (map-only-numbers (lambda (x) (* x 2)) '(2 davis 9 notdavis 12 (lambda (x) 2 DAVIS!))) ;=> '(4 davis 18 notdavis 24 (lambda (x) 2 DAVIS!)) Note how the various Davis-related symbols are not altered, only the numbers. Excellent Create a function map-tree-leaves-into-nodes that takes a tree that satisfies tree? and returns a datatype satisfying smaller-tree?. The returned smaller tree should be functionally the same as the input tree, but without only the leaves removed. (define (tree? t) (match t ['empty #t] [(leaf, (? number?)) #t] [(node, (? number?),to,t1) #t] [_ #f])) (define (smaller-tree? t) (match t ['empty #t] [(node,n,(? smaller-tree?), (? smaller-tree?)) #t] [_ #f])) Example runs: (map-tree-leaves-into-nodes '(node 2 (leaf 4) (node a empty (leaf 12)))) ;=> '(node 2 (node 4 empty empty) (node a empty (node 12 empty empty)))

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!