Question: [higher order function and list programming] It is useful to know where in a list a certain element occurs, or if it occurs at all.

 [higher order function and list programming] It is useful to know

[higher order function and list programming] It is useful to know where in a list a certain element occurs, or if it occurs at all. Write a higher-order function findFirstIndex which takes three formal parameters el, Ist, and pred. It searches for a given element, el in the list Ist with the help of a comparison predicate, pred. The function should return the list position of the (first) match or return O if no match is found. The index count starts from 1. You can assume list ist contains numeric values. Example scripts: $ (define numeq (lambda (x y) (if (= x y) #t #f))) $ (findFirstlndex (list 1 2 6946) 6 numeq) 3 $ (findFirstIndex (list 1649) 3 numeq) 0 $ (findFirstlndex (list 1 2 2 6 4 9) 2 (lambda (x y) (if (

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!