Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Red Nose Hacker
Red Nose Hacker

Posted on

     

Learning Guile - Booleans

Guile Logo

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)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
epsi profile image
E.R. Nurwijayadi
I am not a time traveller.
  • Location
    Jakarta
  • Work
    Mr. at Sunday Market
  • Joined

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

CollapseExpand
 
jeremykorwin profile image
Red Nose Hacker
GNU enthousiast. Free Software & Hardware CraftsmanI love you all. Just tell me how can I help ?
  • Location
    Paris, France
  • Work
    Free 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 !

CollapseExpand
 
epsi profile image
E.R. Nurwijayadi
I am not a time traveller.
  • Location
    Jakarta
  • Work
    Mr. at Sunday Market
  • Joined

Thank you

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

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

GNU enthousiast. Free Software & Hardware CraftsmanI love you all. Just tell me how can I help ?
  • Location
    Paris, France
  • Work
    Free Hard/Software Craftsman
  • Joined

More fromRed Nose Hacker

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp