100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4,6 TrustPilot
logo-home
Otro

CPSC110 problem set 2 solution

Puntuación
-
Vendido
-
Páginas
5
Subido en
05-01-2024
Escrito en
2023/2024

complete solutions for problem set 2

Institución
Grado

Vista previa del contenido

(@problem 1)
;;
;; The following func7on design may have errors in it. Please fix the error
;; or errors that you find. Any changes you make should preserve the exis7ng
;; design intent. NOTE THAT when fixing an error in exis7ng code the best
;; prac7ce is to change as liHle of the code as possible. That is because
;; in most organiza7ons someone will have to review any changes you make,
;; and changing only what you really mean to change will make that person's
;; job easier. Remember always that the goal is to be kind to your fellow
;; programmers.
;;
;; First uncomment the en7re func7on design, and then fix the error.
;; If you are unable to find and fix the error, leave it commented out.
;; Note that when fixing a bug in an exis7ng program your goal should
;; be to have a light touch. If there is a small simple way to fix
;; something then do it the small and simple way.
;;
;; Your solu7on must include @htdf, @signature, and @template-origin tags.

(@htdf stack)
(@signature Image Image -> Image)
;; stack images, widest on boHom, first on boHom if same width
(check-expect (stack (rectangle 10 5 "solid" "blue")
(rectangle 20 9 "solid" "red"))
(above (rectangle 10 5 "solid" "blue")
(rectangle 20 9 "solid" "red")))

(check-expect (stack (rectangle 20 5 "solid" "blue")
(rectangle 20 9 "solid" "red"))
(above (rectangle 20 9 "solid" "red")
(rectangle 20 5 "solid" "blue")))

(check-expect (stack (rectangle 20 5 "solid" "blue")
(rectangle 10 9 "solid" "red"))
(above (rectangle 10 9 "solid" "red")
(rectangle 20 5 "solid" "blue")))

;(define (stack i1 i2) i1) ;stub

(@template-origin Image)

(@template
(define (stack i1 i2)
(... i1 i2)))

, (define (stack i1 i2)
(if (>= (image-width i1) (image-width i2))
(above i2 i1)
(above i1 i2)))


(@problem 2)
;;
;; The following data design may have errors in it. Please fix the error or
;; errors that you find. Any changes you make should preserve the exis7ng
;; design intent. Again, change only the parts of the code you really need
;; to change.
;;
;; Your solu7on must include @htdd tag, @dd-template-rules tag, and a NOT
;; commented fn-for-site template.
;;


(@htdd Site)
;; Site is one of:
;; - "Vancouver"
;; - "Okanagan"
;; - "Robson"
;; - "CDM"
;; interp. a UBC site
;; <Examples are redundant for enumera7ons>

(@dd-template-rules one-of
atomic-dis7nct
atomic-dis7nct
atomic-dis7nct
atomic-dis7nct)

(define (fn-for-site s)
(cond [(string=? s "Vancouver") (...)]
[(string=? s "Okanagan") (...)]
[(string=? s "Robson") (...)]
[(string=? s "CDM") (...)]))

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

Subido en
5 de enero de 2024
Número de páginas
5
Escrito en
2023/2024
Tipo
Otro
Personaje
Desconocido

Temas

$8.49
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
skye3

Conoce al vendedor

Seller avatar
skye3 UBC
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
5
Miembro desde
2 año
Número de seguidores
1
Documentos
9
Última venta
1 año hace

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes