Skip to content

Character

Check if a value is a character

Given a file named “main.scm” with:

(import (scheme base))
(write-u8 (if (char? <expression>) 65 66))

When I successfully run scheme main.scm

Then the stdout should contain exactly “A”.

Examples

expression
#\A
#\newline
(integer->char 65)

Check if a value is a whitespace

Given a file named “main.scm” with:

(import (scheme base) (scheme char))
(write-u8 (if (char-whitespace? <value>) 65 66))

When I successfully run scheme main.scm

Then the stdout should contain exactly “<output>”.

Examples

valueoutput
#\AB
#\newlineA
#\returnA
#\spaceA
#\tabA

Write a character

Given a file named “main.scm” with:

(import (scheme base))
(write-char #\A)

When I successfully run scheme main.scm

Then the stdout should contain exactly “A”.

Write a newline character

Given a file named “main.scm” with:

(import (scheme base))
(write-char #\A)
(newline)
(write-char #\B)

When I successfully run scheme main.scm

Then the stdout should contain exactly:

A
B

Compare characters

Given a file named “main.scm” with:

(import (scheme base))
(write-u8 (if (<predicate> <characters>) 65 66))

When I successfully run scheme main.scm

Then the stdout should contain exactly “<output>”.

Examples

predicatecharactersoutput
char=?#\A #\AA
char=?#\A #\BB
char=?#\A #\A #\AA
char=?#\A #\A #\BB
char<?#\A #\BA
char<?#\A #\AB
char<?#\A #\B #\CA
char<?#\A #\B #\BB