diff options
author | Arun Isaac | 2024-09-05 23:13:27 +0100 |
---|---|---|
committer | Arun Isaac | 2024-09-05 23:35:11 +0100 |
commit | c28c7950c4894dbb7773c4d9a5e52d56c972e5f1 (patch) | |
tree | 216db47df705b25628ea1ac6c0ecde7e6c729ee8 | |
parent | 8501b0319236c4e1c6223df7db3995507c830f48 (diff) | |
download | ravanan-c28c7950c4894dbb7773c4d9a5e52d56c972e5f1.tar.gz ravanan-c28c7950c4894dbb7773c4d9a5e52d56c972e5f1.tar.lz ravanan-c28c7950c4894dbb7773c4d9a5e52d56c972e5f1.zip |
work: Match null type using pattern matching.
* ravanan/work/command-line-tool.scm (vector-empty?): Delete function.
(match-type): Match null type using pattern matching.
-rw-r--r-- | ravanan/work/command-line-tool.scm | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/ravanan/work/command-line-tool.scm b/ravanan/work/command-line-tool.scm index 3af1dcf..ecf11b4 100644 --- a/ravanan/work/command-line-tool.scm +++ b/ravanan/work/command-line-tool.scm @@ -53,10 +53,6 @@ directory after THUNK returns." thunk (cut chdir original-current-directory)))) -(define (vector-empty? vec) - "Return @code{#t} if @var{vec} is empty. Else, return @code{#f}." - (zero? (vector-length vec))) - ;; TODO: Support float types. (define (object-type obj) "Return the type of @var{obj}." @@ -86,10 +82,9 @@ example, when @var{type} is a union type." ((eq? type 'Any) (object-type obj)) ((eq? type 'null) - (and (or (eq? obj 'null) - (and (vector? obj) - (vector-empty? obj))) - 'null)) + (match obj + ((or 'null #()) 'null) + (_ #f))) ((array-type? type) (and (every (cut match-type <> (array-type-subtype type)) (vector->list obj)) |