CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 19:35:28 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=c8fa9746bab9db1e37b1fad77b4dca013b1ba92a65ccb88ee48810bebf92aaa4a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22VdYjID4w9HdX5j4k-iI4Kl3j7GwDvJRK%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d0ccfe69c9c537-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 $2500 in 20 minutes⭐⭐⭐ 4
JavaScript | 2 sec ago | 0.25 KB
-
💵 Make 3000$ in 20 minutes 💵
JavaScript | 6 sec ago | 0.24 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 7 sec ago | 0.25 KB
-
📌 Swapzone +37% glitch ⭐ V
JavaScript | 10 sec ago | 0.25 KB
-
📌 Swapzone +37% glitch
JavaScript | 15 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ 7
JavaScript | 16 sec ago | 0.25 KB
-
📝 Exchange profit method
JavaScript | 25 sec ago | 0.24 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ 1
JavaScript | 25 sec ago | 0.25 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