Professional Documents
Culture Documents
student name
and a list of marks and a pass mark. It returns Boolean true (#t) if the student
marks are more than the input pass mark else returns Boolean false (#f).
Code -
;;Contract:Find_Grade:list,number->boolean
;;Purpose :Program to check whether a student has passed in all subjects or not
given a pass mark.
;;Header :(define Find_Grade(list passmark).....)
;;Examples:
;;(Find_Grade (list "sagar" (list 50 60 70 80) ) 40)
;;O/P:- #t
;;(Find_Grade (list "Shyam" (list 40 23 60 70) ) 24)
;;O/P:- #f
;;Body
(define Find_Grade(lambda(lst pm)
(cond
[(not (list? lst)) -1]
[(null? lst) -1]
[(null? (list-ref lst 1)) -1]
[(not (string? (list-ref lst 0))) -1]
[(not-number? (list-ref lst 1)) -1]
[else (Pass (list-ref lst 1) pm)]
)))
(define not-number?(lambda(lst)
(if(null? lst)
#f
(begin
(if(number? (car lst))
(not-number? (cdr lst))
#t
)
)
)))
;;Test cases
(Find_Grade (list "sagar" (list 50 60 70 80) ) 40)
(Find_Grade (list "student1" (list 40 50 60 70) ) 50)