Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scheme - Convert boolean to string?

I am having a tough time trying to find an example of converting a boolean to a string in Scheme.

My problem is that I use string-append to add a few strings together as part of a debugger. My fix was to check if equal to #t, then append "#t", and like-wise with #f.

My question- is there a method in Scheme to convert bools to strings? Something like bool->string?

My Code:

(if (equal? val #t)
                       (string-append (number->string count) ":" "#t")    
                       (string-append (number->string count) ":" "#f")    )
like image 451
Gaʀʀʏ Avatar asked Dec 27 '22 14:12

Gaʀʀʏ


1 Answers

Use format:

> (format "~a" #t)
"#t"
> (format "~a" #f)
"#f"
like image 140
soegaard Avatar answered Jan 07 '23 02:01

soegaard