PasteRack.org
Paste # 52880
2014-11-23 16:18:17

Fork as a new paste.

Paste viewed 178 times.


Embed:

  1. #lang racket
  2. (define-struct fac (fa ti as le oa))
  3. (define-struct str (s n ff))
  4.  
  5. (define sample
  6.   (list (make-str 'A 'F (make-fac 8 10 13 13 (+ 8 10 13 13)))
  7.         (make-str 'B 'G (make-fac 13 10 12 10 (+ 13 10 12 10)))
  8.         (make-str 'C 'H (make-fac 9 13 11 11 (+ 9 13 11 11)))
  9.         (make-str 'D 'I (make-fac 11 10 12 11 (+ 11 10 12 11)))
  10.         (make-str 'E 'J (make-fac 12 10 12 11 (+ 12 10 12 11)))
  11.         )
  12.   )
  13.  
  14. (define (best-as alon)
  15.   (cond
  16.     [(empty? alon) 0]
  17.     [(> (fac-as (str-fac (first alon)))
  18.         (best-as (rest alon)))
  19.      (string-append (symbol->string (str-s (first alon))) " "
  20.                     (symbol->string (str-n (first alon))) "!")]
  21.     [else (best-as (rest alon))]))

=>