Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

University of British Columbia CPSC 110 LAB 1

Beoordeling
-
Verkocht
-
Pagina's
6
Cijfer
A+
Geüpload op
15-10-2021
Geschreven in
2021/2022

University of British Columbia CPSC 110 LAB 1

Instelling
Vak

Voorbeeld van de inhoud

CPSC 110 LAB 1

HtDF Lab

P3
A (much too) simple scheme for pluralizing words in English is to add an
s at the end unless the word already ends in s.

Design a function that consumes a string, and adds s to the end unless
the string already ends in s.

;; String -> String
;; Adds an s to end of given word, unless word already ends in s
(check-expect (pluralize "hello") "hellos")
(check-expect (pluralize "has") "has")
(check-expect (pluralize "") "")




m
er as
;(define (pluralize str) "") ;stub




co
eH w
;(define (pluralize str)




o.
; (... str)) ;template
rs e
ou urc
(define (pluralize str)
(if (string=? str "")
""
o

(if (string=? "s" (string-ith str (- (string-length str) 1)))
aC s

str
vi y re


(string-append str "s"))))

P4
Design a function called nth-char-equal? that consumes two strings
ed d




and a natural and produces true if the strings both have length greater
ar stu




than n and have the same character at position n.

Note, the signature for such a function is:
;; String String Natural -> Boolean
is




The template for such a function is:
Th




(define (nth-char-equal? s1 s2 n)
(... s1 s2 n))
sh




;; String String Natural -> Boolean
;; Produces true if string-length of s1 and s2 are greater than n and have the same character at position
n
(check-expect (nth-char-equal? "hello" "goodbye" 10) false)
(check-expect (nth-char-equal? "hello" "bell" 6) false)
(check-expect (nth-char-equal? "time" "bath" 3) false)
(check-expect (nth-char-equal? "candy" "mandy" 3) true)


This study source was downloaded by 100000805705997 from CourseHero.com on 10-14-2021 20:45:30 GMT -05:00


https://www.coursehero.com/file/46578028/CPSC-110-LAB-1docx/

, ;(define (nth-char-equal? s1 s2 n) false) ;stub

;(define (nth-char-equal? s1 s2 n)
; (... s1 s2 n)) ;template

(define (nth-char-equal? s1 s2 n)
(if (> (string-length s1) n)
(if (> (string-length s2) n)
(string=? (substring s1 (- n 1) n) (substring s2 (- n 1) n))
false)
false))


Balloon Lab




m
; Balloon popping




er as
co
;; CONSTANTS ==========================




eH w
o.
(define WIDTH 500)
(define HEIGHT 500)
rs e
ou urc
(define MTS (empty-scene WIDTH HEIGHT))

(define BALLOON-COLOUR "red")
o

(define POP-IMAGE (overlay (text "POP!" 80 "black")
(radial-star 30 (/ WIDTH 10) (/ WIDTH 2) "solid" "yellow")))
aC s
vi y re



(define CTR-X (/ WIDTH 2))
(define CTR-Y (/ HEIGHT 2))
ed d




(define SPEED 2)
ar stu




(define MAX-SIZE (/ WIDTH 2))

;; DATA DEFINITIONS ============================
is




;; Balloon is one of:
Th




;; - Number[1, MAX-SIZE]
;; - false
;; interp. number is the radius of balloon in screen pixels, false means balloon is popped
sh




(define B1 1)
(define B2 false)
(define B3 10)
(define B4 MAX-SIZE)

(define (fn-for-balloon b)
(cond [(and (number? b)


This study source was downloaded by 100000805705997 from CourseHero.com on 10-14-2021 20:45:30 GMT -05:00


https://www.coursehero.com/file/46578028/CPSC-110-LAB-1docx/

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
15 oktober 2021
Aantal pagina's
6
Geschreven in
2021/2022
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

$3.49
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF


Ook beschikbaar in voordeelbundel

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
StuviaGuides West Virgina University
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
16183
Lid sinds
7 jaar
Aantal volgers
8362
Documenten
5972
Laatst verkocht
7 uur geleden
Accounting, Finance, Statistics, Computer Science, Nursing, Chemistry, Biology & More — A+ Test Banks, Study Guides & Solutions

As a Top 1st Seller on Stuvia and a nursing professional, my mission is to be your light in the dark during nursing school and beyond. I know how stressful exams and assignments can be, which is why I’ve created clear, reliable, and well-structured resources to help you succeed. I offer test banks, study guides, and solution manuals for all subjects — including specialized test banks and solution manuals for business books. My materials have already supported countless students in achieving higher grades, and I want them to be the guide that makes your academic journey easier too. I’m passionate, approachable, and always focused on quality — because I believe every student deserves the chance to excel.

Lees meer Lees minder
4.3

2292 beoordelingen

5
1569
4
305
3
183
2
74
1
161

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen