Skip to content

Instantly share code, notes, and snippets.

@shakdwipeea
Created April 4, 2019 18:56
Show Gist options
  • Select an option

  • Save shakdwipeea/cab4c27af6b8827e75a84ba7215bc9f7 to your computer and use it in GitHub Desktop.

Select an option

Save shakdwipeea/cab4c27af6b8827e75a84ba7215bc9f7 to your computer and use it in GitHub Desktop.
#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