Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Why am I getting this error string - trim: undefined; cannot reference an identifier before its definition? ( define ( valid - whoozit? s )

Why am I getting this error "string-trim: undefined;
cannot reference an identifier before its definition"?
(define (valid-whoozit? s)
(and (=(string-ref s 0) #\x)
(>(string-length s)1)
(string-contains s "y")))
(define (valid-whatzit? s)
(and (=(string-ref s 0) #\q)
(>(string-length s)2)
(or (string-contains s "z")
(string-contains s "d"))
(valid-blurb? (substring s 2))))
(define (valid-blurb? s)
(cond ((string-empty? s) #t)
((valid-whoozit? s)
(valid-blurb? (substring s (string-length (match0))))))
((valid-whatzit? s)
(valid-blurb? (substring s (string-length (match0))))))
(define (main)
(display "Enter an alien word: ")
(let loop ()
(let ((input (string-trim (read))))
(if (valid-blurb? input)
(display "The word is fine.")
(begin
(display "The word is a mess!")
(newline)
(loop))))))
(main)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

Students also viewed these Databases questions

Question

Evaluate indefinite integral J sec3 x dx

Answered: 1 week ago

Question

Decision Making in Groups Leadership in Meetings

Answered: 1 week ago