Question: Below is a question that I have issues with I have code but not working if you could help me to figure it out it

Below is a question that I have issues with I have code but not working if you could help me to figure it out it would be much appreciated. Below the question is my current code. Not sure how to test it either

Write before-in-list?, which takes a list and two elements of the list. It should return #t if the second argument appears in the list argument before the third argument: > (before-in-list? '(back in the ussr) 'in 'ussr) #T > (before-in-list? '(back in the ussr) 'the 'back) #F

The procedure should also return #f if either of the supposed elements doesn't appear at all.

; Write before-in-list?, which takes a list and two elements of the list. It

; should return #t if the second argument appears in the list argument before the third

; argument: ; ; > (before-in-list? (back in the ussr) in ussr) ; #T

; ; > (before-in-list? (back in the ussr) the back) ; #F

; ; The procedure should also return #f if either of the supposed elements doesnt appear

; at all.

(define (before-in-list? lst a b)

(cond

((null? lst) #f)

((equal? (car lst) a) (member? b (cdr lst)))

((equal? (car lst) b) #f)

(else (before-in-list? (cdr lst) a b))))

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 Databases Questions!