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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3a0a5237b4_40466f3a0a498f06.jpg)
[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
Get step-by-step solutions from verified subject matter experts
