From bf7c73f9bed76e34b89da3823bad8893493e7099 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Sat, 1 Oct 2022 17:13:34 +0300 Subject: [PATCH] Added true? and false? --- README.md | 2 +- stdlib/stdlib.lisp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 77551d5..6089ad4 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ We have a reasonable number of functions implemented, either in our golang core Building upon those primitives we have a larger standard-library of functions written in Lisp such as: -* `abs`, `apply`, `append`, `cond`, `count`, `filter`, `lower`, `map`, `min`, `max`, `ms`, `nat`, `neg`, `now`, `nth`, `reduce`, `repeat`, `reverse`, `seq`, `strlen`, `upper`, `when`, `while`, etc. +* `abs`, `apply`, `append`, `cond`, `count`, `false?`, `filter`, `lower`, `map`, `min`, `max`, `ms`, `nat`, `neg`, `now`, `nth`, `reduce`, `repeat`, `reverse`, `seq`, `strlen`, `true?`, `upper`, `when`, `while`, etc. Although the lists above should be up to date you can check the definitions to see what is currently available: diff --git a/stdlib/stdlib.lisp b/stdlib/stdlib.lisp index f70415b..f35672c 100644 --- a/stdlib/stdlib.lisp +++ b/stdlib/stdlib.lisp @@ -86,6 +86,11 @@ (define even? (lambda (n) (zero? (% n 2)))) (define odd? (lambda (n) (! (even? n)))) +;; +;; is the given argument "true", or "false"? +;; +(def! true? (fn* (arg) (if (eq #t arg) true false))) +(def! false? (fn* (arg) (if (eq #f arg) true false))) ;; Square root (define sqrt (lambda (x:number) (# x 0.5)))