The two boolean values are: "true" and "false". Respectively#t
or#true
and#f
or#false
in Guile.
In a conditional test context, "true" means any expression other than#f
or#false
.
Here is a small test suite that illustrates all this:
(use-modules(srfisrfi-64))(test-begin"test-suite")(test-equal"Truth"#t#true)(test-equal"Falsness"#f#false)(test-equal"Numbers are true"#t(if12547#t#f))(test-equal"Strings are true"#t(if"I am not false"#t#f))(test-equal"Lists - even empty - are true"#t(if'()#t#f))(test-equal"Symbols are not false"#f(not'i-am-not-false))(test-end"test-suite")
Create a/tmp/bool.scm
file with the code below. Run the tests and if everything goes well, you should see the following result:
$ guile bool.scm ;;;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0;;; or pass the --no-auto-compile argument to disable.;;;; compiling /tmp/bool.scmcompiled /home/jeko/.cache/guile/ccache/3.0-LE-8-4.3/tmp/bool.scm.go%%%% Starting test-suite (Writing full log to "test-suite.log")# of expected passes 6
If you feel like it, you can tweak this file to experiment!
Top comments(3)

I wonder if there is a community where I can ask about Guile.

- LocationParis, France
- WorkFree Hard/Software Craftsman
- Joined
Damn I haven't seen any notification about your comment !
There is a community !
You can find it on the Guile mailing list, or on the Scheme sub-Reddit, or on StackOverflow, or on Discord Scheme server, or you can send me e-mails !

Thank you
For further actions, you may consider blocking this person and/orreporting abuse