Created
April 4, 2019 18:56
-
-
Save shakdwipeea/cab4c27af6b8827e75a84ba7215bc9f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| (struct student (roll name marks)) | |
| (define (get-input!) | |
| (read-line (current-input-port))) | |
| (define (get-number!) (string->number (get-input!))) | |
| (displayln "Enter the number of students") | |
| (define num-students (get-number!)) | |
| (define class (foldl (λ (n c) | |
| (displayln "Enter name") | |
| (define name (get-input!)) | |
| (displayln "Enter marks") | |
| (define marks (get-number!)) | |
| (append c (list (student n name marks)))) | |
| '() | |
| (range num-students))) | |
| (map (λ (c) | |
| (printf "~a~v~a\n" (student-roll c) (student-name c) (student-marks c))) | |
| class) | |
| (define class-marks (map student-marks class)) | |
| (define average (/ (apply | |
| + (map student-marks class)) num-students)) | |
| (define greater-marks (filter (lambda (arg) | |
| (> arg average)) | |
| class-marks)) | |
| (define less-marks (filter (lambda (arg) | |
| (< arg average)) | |
| class-marks))% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment