Advertisement
cardel

OrdenamientoEstructuras

Nov 11th, 2016
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.64 KB | None | 0 0
  1. (define-struct email (remitente destinatario mensaje))
  2.  
  3. (define l (list
  4.            (make-email "pedro" "maria" "hola xD")
  5.            (make-email "carlos" "juan" "¿como anda?")
  6.            (make-email "ana" "juana" "te odio :)")        
  7.                 )
  8.   )
  9.  
  10. (define (intro n lst)
  11.   (cond
  12.     [(empty? lst) (list n)]
  13.     [else
  14.      (cond
  15.        [(string<? (email-remitente n) (email-remitente (first lst))) (cons n lst)]
  16.        [else (cons (first lst) (intro n (rest lst)))]
  17.        )
  18.      ]
  19.     )
  20.   )
  21.  
  22. (define (ordenar lst)
  23.   (cond
  24.     [(empty? lst) empty]
  25.     [else
  26.      (intro (first lst) (ordenar (rest lst)))
  27.      ]
  28.     )
  29.   )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement