Skip to content

Instantly share code, notes, and snippets.

@elderica
Created January 16, 2023 11:06
Show Gist options
  • Save elderica/f305c8c172e8599bee447d6b55f17c79 to your computer and use it in GitHub Desktop.
Save elderica/f305c8c172e8599bee447d6b55f17c79 to your computer and use it in GitHub Desktop.
#lang racket
(struct plan
(type
data-amount
price)
#:transparent)
(define plans-voice
(vector
(plan 'voice 2 850)
(plan 'voice 4 990)
(plan 'voice 8 1500)
(plan 'voice 15 1800)
(plan 'voice 20 2000)))
(define plans-esim
(vector
(plan 'esim 2 440)
(plan 'esim 4 660)
(plan 'esim 8 1100)
(plan 'esim 15 1430)
(plan 'esim 20 1650)))
(define plans (vector-append plans-voice plans-esim))
(vector-sort plans <
#:key (lambda (p) (/ (plan-data-amount p) (plan-price p))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment