Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using dr racket redesign find-path/list so that it uses an existing list abstraction from figures 95 and 96 instead of explicit structural recursion. Hint Read

Using dr racket redesign find-path/list so that it uses an existing list abstraction from figures 95 and 96 instead of explicit structural recursion. Hint Read the documentation for Rackets ormap. How does it differ from ISL+s ormap function? Would the former be helpful here?

image text in transcribed

image text in transcribed

trl+s ]N [N -X] -[List-of X] ; constructs a list by applying f to , 1, , (sub1 n) ; (build-list n f)-(list (f ) (f (-n 1))) (define (build-listnf) ...) ; [X] [XBoolean] [List-of X] - [List-of X] ; produces a list from those items on lx for which p holds (define (filter p ) ) ; [X] [List-of X] [X X - Boolean] -[List-of X] ; produces a version of that is sorted according to cmp (define (sort lx cmp) ...) ; [XY] [X-> Y] [List-of X] -> [List-of Y] ; constructs a list by applying f to each item on ; (map f (list x-1 X-n))(list (f x-1) (f x-n)) (define (map f lx) ...) ; [X] [XBoolean] [List-of X] - Boolean ; determines whether p holds for every item on lx ; (andmap p (list x-1 x-n)) -= (and (p x-1) (p x-n)) (define (andmap p lx) ...) ; [X] [XBoolean] [List-of X] - Boolean ; determines whether p holds for at least one item on lx ; (ormap p (listx-1 x-n)) -(or (p x-1) (p x-n)) (define (ormap p ) ) ; applies f from right to left to each item in lx and b ; (foldr f b (list x-1 x-n))(f x-1 (f x-n b)) (define (foldr f b ) ) (foldr0'(1 2 3 4 5)) (+1 (+2 12)) ; applies f from left to right to each item in lx and b ; (foldl f b (list x-1 x-n))(f x-n (f x-1 b)) (define (foldl f b ) ) (foldl0'(1 2 3 4 5)) 5 (+4 6)) - (+ 5 10) Figure 96: ISL's abstract functions for list processing (2) trl+s ]N [N -X] -[List-of X] ; constructs a list by applying f to , 1, , (sub1 n) ; (build-list n f)-(list (f ) (f (-n 1))) (define (build-listnf) ...) ; [X] [XBoolean] [List-of X] - [List-of X] ; produces a list from those items on lx for which p holds (define (filter p ) ) ; [X] [List-of X] [X X - Boolean] -[List-of X] ; produces a version of that is sorted according to cmp (define (sort lx cmp) ...) ; [XY] [X-> Y] [List-of X] -> [List-of Y] ; constructs a list by applying f to each item on ; (map f (list x-1 X-n))(list (f x-1) (f x-n)) (define (map f lx) ...) ; [X] [XBoolean] [List-of X] - Boolean ; determines whether p holds for every item on lx ; (andmap p (list x-1 x-n)) -= (and (p x-1) (p x-n)) (define (andmap p lx) ...) ; [X] [XBoolean] [List-of X] - Boolean ; determines whether p holds for at least one item on lx ; (ormap p (listx-1 x-n)) -(or (p x-1) (p x-n)) (define (ormap p ) ) ; applies f from right to left to each item in lx and b ; (foldr f b (list x-1 x-n))(f x-1 (f x-n b)) (define (foldr f b ) ) (foldr0'(1 2 3 4 5)) (+1 (+2 12)) ; applies f from left to right to each item in lx and b ; (foldl f b (list x-1 x-n))(f x-n (f x-1 b)) (define (foldl f b ) ) (foldl0'(1 2 3 4 5)) 5 (+4 6)) - (+ 5 10) Figure 96: ISL's abstract functions for list processing (2)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Ehs 2.0 Revolutionizing The Future Of Safety With Digital Technology

Authors: Tony Mudd

1st Edition

B0CN69B3HW, 979-8867463663

More Books

Students also viewed these Databases questions