scheme scheme scheme scheme

学习 时间:2026-04-07 16:28:53 阅读:2769
scheme scheme scheme scheme

最佳回答

故意的彩虹

简单的溪流

2026-04-07 16:28:53

(define-struct student (ID name score));contract:findTopper:list->number;purpso:To find the 10 of the student who scored the highest ,given a instances of type student;example:(findTopper (list (make-student 2324 "Seenu" 60) (make-student 5678 "Cherry" 100) (make-student 8901 "Micky" 40) (make-student 5839 "David" 30)(define findTopper(lambda (studentList)(let traverseStudentList((lengthList (length studentList))(index 1 )(currentTopper (list-ref studentList 0))) (if (< index lengthList)(if (> (student-score (list-ref studentList index )) (student-score currentTopper))(begin(set!currentTopper (list-ref studentList index))(traverseStudentList lengthList (+ index 1) currentTopper))(traverseStudentList lengthList (+ index 1) currentTopper))(student-ID currentTopper))))) (define-struct student (ID name score));contract:findTopper:list->number;purpso:To find the 10 of the student who scored the highest ,given a instances of type student;example:(findTopper (list (make-student 2324 "Seenu" 60) (make-student 5678 "Cherry" 100) (make-student 8901 "Micky" 40) (make-student 5839 "David" 30)))(define findTopper(lambda (studentList)(if (and (list?studentList) (not (null?studentList))) (validateList studentList))(let traverseStudentList((lengthList (length studentList))(index 1 )(currentTopper (list-ref studentList 0))) (if (< index lengthList)(if (> (student-score (list-ref studentList index )) (student-score currentTopper))(begin(set!currentTopper (list-ref studentList index))(traverseStudentList lengthList (+ index 1) currentTopper))(traverseStudentList lengthList (+ index 1) currentTopper))(student-ID currentTopper)))(display"Invalid Input"))) ;contract:validateList:list->boolean;purpose:To check if all the elements of list is of type student;;example:(validateList (list (make-student 2324 "Seenu" 60) (make-student 5678 "Cherry" 100) (make-student 8901 "Micky" 40) (make-student 5839 "David" 30)))(define validateList(lambda (studentList)(if (not (null?studentList))(if (not (student?(car studentList)))#f(validateList (cdr studentList)))#t)))

最新回答共有2条回答

  • 优美的冬瓜
    回复
    2026-04-07 16:28:53

    (define-struct student (ID name score));contract:findTopper:list->number;purpso:To find the 10 of the student who scored the highest ,given a instances of type student;example:(findTopper (list (make-student 2324 "Seenu" 60) (make-student 5678 "Cherry" 100) (make-student 8901 "Micky" 40) (make-student 5839 "David" 30)(define findTopper(lambda (studentList)(let traverseStudentList((lengthList (length studentList))(index 1 )(currentTopper (list-ref studentList 0))) (if ( (student-score (list-ref studentList index )) (student-score currentTopper))(begin(set!currentTopper (list-ref studentList index))(traverseStudentList lengthList (+ index 1) currentTopper))(traverseStudentList lengthList (+ index 1) currentTopper))(student-ID currentTopper))))) (define-struct student (ID name score));contract:findTopper:list->number;purpso:To find the 10 of the student who scored the highest ,given a instances of type student;example:(findTopper (list (make-student 2324 "Seenu" 60) (make-student 5678 "Cherry" 100) (make-student 8901 "Micky" 40) (make-student 5839 "David" 30)))(define findTopper(lambda (studentList)(if (and (list?studentList) (not (null?studentList))) (validateList studentList))(let traverseStudentList((lengthList (length studentList))(index 1 )(currentTopper (list-ref studentList 0))) (if ( (student-score (list-ref studentList index )) (student-score currentTopper))(begin(set!currentTopper (list-ref studentList index))(traverseStudentList lengthList (+ index 1) currentTopper))(traverseStudentList lengthList (+ index 1) currentTopper))(student-ID currentTopper)))(display"Invalid Input"))) ;contract:validateList:list->boolean;purpose:To check if all the elements of list is of type student;;example:(validateList (list (make-student 2324 "Seenu" 60) (make-student 5678 "Cherry" 100) (make-student 8901 "Micky" 40) (make-student 5839 "David" 30)))(define validateList(lambda (studentList)(if (not (null?studentList))(if (not (student?(car studentList)))#f(validateList (cdr studentList)))#t)))

上一篇 要参加讲故事比赛,谁能提供一些符合我这个年龄段的小故事参加比赛

下一篇 孔子拜师的故事说一下