Symbol
Write a symbol
Section titled “Write a symbol”Given a file named “main.scm” with:
(import (scheme base))
(write-string (symbol->string 'foo))
When I successfully run stak main.scm
Then the stdout should contain exactly “foo”.
Convert a string to an existing symbol
Section titled “Convert a string to an existing symbol”Given a file named “main.scm” with:
(import (scheme base))
(write-u8 (if (eq? (string->symbol "foo") 'foo) 65 66))
When I successfully run stak main.scm
Then the stdout should contain exactly “A”.
Convert a string to a new symbol
Section titled “Convert a string to a new symbol”Given a file named “main.scm” with:
(import (scheme base))
(write-u8 (if (eq? (string->symbol "foo") (string->symbol "foo")) 65 66))
When I successfully run stak main.scm
Then the stdout should contain exactly “A”.
Check symbol equality
Section titled “Check symbol equality”Given a file named “main.scm” with:
(import (scheme base))
(write-u8 (if (symbol=? <symbols>) 65 66))
When I successfully run stak main.scm
Then the stdout should contain exactly “<output>”.
Examples
Section titled “Examples”symbols | output |
---|---|
’foo ‘foo | A |
’foo ‘bar | B |
’foo ‘foo ‘bar | B |