Merge pull request #358 from bjh21/bjh21-extra-tests
[jackhill/mal.git] / guile / types.scm
index a5314eb..7329cd5 100644 (file)
 
 (library (types)
   (export string-sub *eof* non-list?
-          string->keyword _keyword?
+          string->keyword _keyword? _string?
           nil _nil? list->hash-map
           cond-true? make-anonymous-func
           make-atom atom? atom-val atom-val-set!
           make-callable callable? callable-is_macro
           callable-is_macro-set! callable-closure
-          is-func? is-macro? make-func callable-apply
+          is-func is-func? is-macro is-macro? make-func callable-apply
           callable-unbox-set! callable-unbox
           callable-meta-info hash-table-clone
           box? box unbox)
   (string-append "\u029e" str))
 
 (define (_keyword? k)
-  (and (string? k) (if (string-match "^\u029e" k) #t #f)))
+  (and (string? k)
+       (> (string-length k) 0)
+       (char=? #\1236 (string-ref k 0))))
+
+(define (_string? s)
+  (and (string? s) (not (_keyword? s))))
 
 (define-record-type mal-nil)
 
        (eq? (callable-is_macro c) b)
        c))
 
-(define (is-func? c) (callable-check c #f))
-(define (is-macro? c) (callable-check c #t))
+(define (is-func c) (callable-check c #f))
+(define (is-func? c) (and (is-func c) #t))
+(define (is-macro c) (callable-check c #t))
+(define (is-macro? c) (and (is-macro c) #t))
 
 (define (hash-table-clone ht)
   (list->hash-map (hash-fold (lambda (k v p) (cons k (cons v p))) '() ht)))