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

CPSC110 Pset7 solution

Puntuación
-
Vendido
-
Páginas
8
Grado
A
Subido en
16-11-2025
Escrito en
2025/2026

This is the correct and the latest solution for pset 7.

Institución
Grado









Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

Subido en
16 de noviembre de 2025
Número de páginas
8
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

Vista previa del contenido

;​; DO NOT PUT ANYTHING PERSONALLY IDENTIFYING BEYOND YOUR CWL IN THIS​
​FILE.​
​;; YOUR CWLs WILL BE SUFFICIENT TO IDENTIFY YOU.​
​;;​
​(require spd/tags)​

​(@assignment psets/pset-07); Do not edit or remove this tag​

​(@problem 1)​

;​; There is a primitive type called 1String, defined as follows:​
​;;​
​;; 1String is String​
​;; interp. a 1String represents a single letter​
​;; CONSTRAINT: any 1String is only one letter long​

(​ @htdd ListOf1String)​
​;; ListOf1String is one of:​
​;; - empty​
​;; - (cons 1String ListOf1String)​
​;; interp. a sequence of letters​

(​ define L1 empty)​
​(define L2 (list "a" "B" "c"))​

(​ @htdd Operations)​
​;; Operations is one of:​
​;; - empty​
​;; - (cons "keep" Operations)​
​;; - (cons "space" Operations)​
​;; - (cons "remove" Operations)​
​;; interp. a sequence of operations to apply to a list of 1String​
​;; "keep" means keep the corresponding letter​
​;; "space" means replace the corresponding letter with a " "​
​;; "remove" means remove the corresponding letter​


(​ @htdf decoder)​
​(@signature ListOf1String Operations -> String)​
​;; produce string containing letters in l with operations applied​
​(check-expect (decoder empty empty) "")​
​(check-expect (decoder empty (list "keep")) "")​
​(check-expect (decoder empty (list "space")) "")​
​(check-expect (decoder empty (list "remove")) "")​
​(check-expect (decoder (list "h" "i") empty) "hi")​
​(check-expect (decoder (list "h" "o" "w") (list "keep" "keep" "keep"))​
​"how")​
​(check-expect (decoder (list "o" "h") (list "space" "space"))​

, "​ ")​
​(check-expect (decoder (list "a" "d" "d") (list "remove" "remove"))​
​"d")​
​(check-expect (decoder (list "i" "k" "l" "h" "a" "m" "k" "s" "a" "r" "m")​
​(list "keep" "remove" "remove" "space" "keep" "keep"​
​"space" "keep" "keep" "remove" "keep"))​
​"i am sam")​

​(check-expect (decoder (list "e" "s" "r" "a" "m" "d" "i" "f" "a" "m")​
​(list "remove" "keep" "remove" "keep" "keep" "space"​
​"keep" "space"))​
​"sam i am")​


​ |​
#
​CROSS PRODUCT OF TYPE-COMMENTS TABLE​

​l-> empty (cons 1String ListOf1String)​
​ops​


​empty (string-append (first l) ;(2)​
​(decoder (rest l)​
​empty))​


​(cons "keep" "" (1) (string-append (first l) ;(3)​
​Operations) (decoder (rest l)​
​(rest ops)))​


​(cons "space" (string-append " " ;(4)​
​Operations) (decoder (rest l)​
​(rest ops)))​


​(cons "remove" (decoder (rest l) (rest ops)) ;(5)​
​Operations)​
​|#​

​(@template-origin 2-one-of)​

​(define (decoder l ops)​
​(cond [(empty? l) ""] ;(1)​
​[(empty? ops) ;(2)​
​(string-append (first l)​
​(decoder (rest l)​
​empty))]​
$10.06
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
06shyun1211

Conoce al vendedor

Seller avatar
06shyun1211 University of British Columbia
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
Nuevo en Stuvia
Miembro desde
3 semanas
Número de seguidores
0
Documentos
8
Última venta
-

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