Advertisement
kevindaprah

Editar atributo de una estructura de estructura?

Jun 29th, 2019
855
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.62 KB | None | 0 0
  1. ;#lang racket
  2.  
  3. (define-struct
  4.  
  5.   cel
  6.  
  7.   (imei marca color))
  8.  
  9. (define-struct
  10.  
  11.   marca
  12.  
  13.   (samsung lg xiaomi))
  14.  
  15. (define-struct
  16.  
  17.   color
  18.  
  19.   (amarillo negro rojo))
  20.  
  21. (define cel1 (make-cel 123456789 (make-marca 'A50 'K39 'MI9) (make-color 'si 'no 'si)))
  22.  
  23. ;(marca-samsung (cel-marca cel1))
  24.  
  25. (define (cambiar-color opcion etruct dato)
  26.  
  27.   (cond
  28.  
  29.     [(= opcion 1) (make-cel (cel-imei etruct)
  30.  
  31.                             (cel-marca etruct)
  32.  
  33.                             (make-color (cel-color etruct) (color-negro (cel-color etruct)) (color-rojo (cel-color etruct))))]
  34.  
  35.     )
  36.  
  37.   )
  38.  
  39. (cambiar-color 1 cel1 'no)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement