Exercise: Strings of colours
A String of favourite colours
Create a string containing the names and favourite colours of each person near you.
For example: "Our favourite colours are green and purple"
""
xthe evaluation will appear here (soon)...
Does the string contain your favorite colour
Use a function to see if a string contains a colour. See the Hint below if you are not sure how to start
For example, does the string "Rachel of York gave brown bread in vans" contain the colour brown?
()
the evaluation will appear here (soon)...
The clojure.stringclojure.string library
Remember that there are specific functions you can use in the clojure.string
library
- clojure.string/split - split a string based on a pattern (regex)
- clojure.string/subs - get part of a string
- clojure.string/replace - replace part of the string based on a pattern (regex)
- clojure.string/includes? - does a string include another string (true or false)