CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 12:33:23 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=b753d004635ad2beafc8618bdcecf0d1c493e6a303f4ea3c5d99d52f8e539adca%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22vHh7o4h38xNLu7MIGFxXu7fPlBT3EydJ%22%3B%7D; HttpOnly; Path=/
cf-ray: 98ce62b8881de084-BLR
FDP Ejercicio - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;Estructuras
- (define-struct fruta (nombre pesoG valorG))
- (define-struct carne (nombre tipo pesoG))
- (define-struct carne-cerdo (parte precioG))
- (define-struct carne-pollo (parte tipo precioG))
- (define-struct carne-res (parte proceso precioG))
- (define-struct carne-pescado (tipo origen precioG))
- (define-struct electrodomestico (nombre marca precioU))
- (define-struct higiene (nombre marca precioD))
- (define-struct bebidas (nombre marca precioU))
- (define-struct venta (producto unidades))
- (define-struct detallado (subtotal IVA bolsas total))
- ;;;Solución
- ;;Autor: Carlos A Delgado
- ;;Fecha 22 de Agosto de 2020
- ;;Contrato: calcular-venta: lista de venta, numero -> detallado
- ;;Propósito: Calcular el total detallado de una venta que de realiza en un supermercado
- ;;Ejemplo
- ; Voy a comprar 150 manzanas gramo cuesta 8, tres mil gramos
- ; de lomo de cerdo 15 el gramo y una lavadora 200000. 3 bolsas
- ; Detallado: Subtotal: 150*8 + 15*3000 + 200000 = 246200
- ; IVA: 0.05(150*8 + 15*3000 ) + 0.19*200000 = 40310
- ; Bolsas= 3*40 = 120
- ; Total: 286630
- (define (calcular-venta lventa num_bolsas)
- (make-detallado
- (calcular-subtotal lventa)
- (calcular-iva lventa)
- (* 40 num_bolsas)
- (+ (calcular-subtotal lventa)
- (calcular-iva lventa)
- (* 40 num_bolsas)
- )))
- ;;Contrato: calcular-subtotal: lista de venta -> numero
- (define (calcular-subtotal lventa)
- (cond
- [(null? lventa) 0]
- [(fruta? (venta-producto (first lventa)))
- (+
- (*
- ;;Número de gramos que voy a comprar
- (venta-unidades (first lventa))
- ;;Valor por gramo
- (fruta-valorG (venta-producto (first lventa)))
- )
- ;;Resto
- (calcular-subtotal (rest lventa))
- )
- ]
- [(carne? (venta-producto (first lventa)))
- (+
- ;;Primero
- (*
- ;;Número de gramos que voy a comprar
- (venta-unidades (first lventa))
- ;;Precio por gramo
- (cond
- [(carne-cerdo? (carne-tipo (venta-producto (first lventa))))
- (carne-cerdo-precioG (carne-tipo (venta-producto (first lventa))))
- ]
- [(carne-pollo? (carne-tipo (venta-producto (first lventa))))
- (carne-pollo-precioG (carne-tipo (venta-producto (first lventa))))
- ]
- [(carne-res? (carne-tipo (venta-producto (first lventa))))
- (carne-res-precioG (carne-tipo (venta-producto (first lventa))))
- ]
- [(carne-pescado? (carne-tipo (venta-producto (first lventa))))
- (carne-pescado-precioG (carne-tipo (venta-producto (first lventa))))
- ]
- [else (error "Tipo de carne no válido")]
- )
- )
- ;;Resto
- (calcular-subtotal (rest lventa))
- )
- ]
- [(higiene? (venta-producto (first lventa)))
- (+
- ;;Primero
- (*
- ;;Número de docenas que voy a comprar
- (venta-unidades (first lventa))
- ;;Valor por docena
- (higiene-precioD (venta-producto (first lventa)))
- )
- ;;Resto
- (calcular-subtotal (rest lventa))
- )
- ]
- [(electrodomestico? (venta-producto (first lventa)))
- (+
- ;;Primero
- (*
- ;;Número de unidades que voy a comprar
- (venta-unidades (first lventa))
- ;;Valor por unidad
- (electrodomestico-precioU (venta-producto (first lventa)))
- )
- ;;Resto
- (calcular-subtotal (rest lventa))
- )]
- [(bebidas? (venta-producto (first lventa)))
- (+
- ;;Primero
- (*
- ;;Número de unidades que voy a comprar
- (venta-unidades (first lventa))
- ;;Valor por unidad
- (bebidas-precioU (venta-unidades (first lventa)))
- )
- ;;Resto
- (calcular-subtotal (rest lventa))
- )]
- [else (error "La lista contiene un producto no válido")]
- ))
- ;;calcular-iva: lista de venta -> numero
- (define (calcular-iva listaV)
- (cond
- [(empty? listaV) 0]
- [else
- (+
- (cond
- [(or (fruta? (venta-producto (first listaV)))
- (carne? (venta-producto (first listaV))))
- (* 0.05 (calcular-subtotal (cons (first listaV) empty)))]
- [else (* 0.19 (calcular-subtotal (cons (first listaV) empty)))]
- )
- (calcular-iva (rest listaV))
- )]))
- ;;Pruebas
- ; Voy a comprar 150 manzanas gramo cuesta 8, tres mil gramos
- ; de lomo de cerdo 15 el gramo y una lavadora 200000. 3 bolsas
- ; Detallado: Subtotal: 150*8 + 15*3000 + 200000 = 246200
- ; IVA: 0.05(150*8 + 15*3000 ) + 0.19*200000 = 40310
- ; Bolsas= 3*40 = 120
- ; Total: 286630
- (check-expect (calcular-venta (cons (make-venta (make-fruta "manzana" 150 8) 150)
- (cons (make-venta (make-carne "Cerdo" (make-carne-cerdo "lomo" 15) 200) 3000)
- (cons (make-venta (make-electrodomestico "Lavadora" "LG" 200000) 1)
- empty))) 3)
- (make-detallado
- 246200
- 40310
- 120
- 286630)
- )
Advertisement
Add Comment
Please, Sign In to add comment
-
✅⭐ Make huge profits on trading ⭐⭐ J
JavaScript | 3 sec ago | 0.24 KB
-
⭐ ✅ Free Products Method ✅ ✅ NEVER SEEN BEFOR...
JavaScript | 6 sec ago | 0.24 KB
-
⭐⭐Exchange Exploit⭐⭐ 1
JavaScript | 8 sec ago | 0.24 KB
-
⭐✅ MAKE $2500 IN 15 MIN⭐⭐⭐ 4
JavaScript | 15 sec ago | 0.24 KB
-
⭐ G2A Bug ⭐ (Get more on BTC swaps) ✅ NEVER S...
JavaScript | 15 sec ago | 0.24 KB
-
⭐✅ Jack's Profit Method ✅ NEVER SEEN BEF...
JavaScript | 24 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ C
JavaScript | 26 sec ago | 0.24 KB
-
⭐✅ Online Marketplace Exploit ✅ NEVER SEEN BE...
JavaScript | 33 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand