i am trying to use string-prefix? but getting error unbound identifier in module
(string-prefix? "Racket" "R")
using drracket
please help
i am trying to use string-prefix? but getting error unbound identifier in module
(string-prefix? "Racket" "R")
using drracket
please help
TL;DR: add (require racket/string)
at the second line of your file, and it will probably work.
Normally, this will work:
#lang racket
(string-prefix? "Racket" "R")
However, there are two possibilities why string-prefix?
could be unbound.
You are using a non-standard Racket language, and the language doesn't provide string-prefix?
. An easy way to check if this is the case is to look at the first line of your program and see if you have #lang <lang-id>
where <lang-id>
is not racket
. For instance:
#lang racket/base
(string-prefix? "Racket" "R")
Here, string-prefix?
is unbound because racket/base
doesn't provide string-prefix?
.
#lang
in the first line of your program, but the bottom-left corner will indicate the language that you are using (e.g., Beginning Student).In both cases, if the language provides the require
construct, then simply adding (require racket/string)
will make string-prefix?
available to you. This is because string-prefix?
is defined in racket/string
.
#lang racket/base
(require racket/string)
(string-prefix? "Racket" "R")