This Scheme code demonstrates working with strings and characters, which is the closest equivalent to Go’s concept of strings and runes. Here are some key points:
Scheme doesn’t distinguish between bytes and characters in strings. Strings are sequences of characters.
We use string-length to get the length of a string, which returns the number of characters.
There’s no direct byte-level access to strings in Scheme. Instead, we can convert the string to a list of characters and iterate over them.
Scheme doesn’t have a built-in concept of Unicode code points. Character handling depends on the implementation.
We use string-ref to access individual characters in a string by index.
The examine-char function demonstrates how to compare characters. Note that the exact representation of non-ASCII characters may vary between Scheme implementations.
To run this Scheme code, you would typically save it to a file (e.g., strings-and-chars.scm) and then use a Scheme interpreter or compiler to execute it. The exact command may vary depending on your Scheme implementation, but it might look something like this:
Note that the output may vary depending on how your Scheme implementation handles Unicode characters and how it represents character codes.