git @ Cat's Eye Technologies Robin / master stdlib / env-p.robin
master

Tree @master (Download .tar.gz)

env-p.robin @masterraw · history · blame

;'<<SPEC'

    -> Tests for functionality "Evaluate Robin Expression (with Env)"

`env?` evaluates its single argument, and evaluates to `#t` if
and only if it is a well-formed binding alist.

    | (env? (literal ((a 1) (b 2) (c 3))))
    = #t

    | (env? (literal ((a 1) (999 2) (c 3))))
    = #f

    | (env? (literal ((a 1) (b 2) c)))
    = #f

    | (env? 7)
    = #f

    | (env? (env))
    = #t

'<<SPEC'

(define env? (fun (li)
  (bind env?-r (fun (self li)
    (if (empty? li)
      #t
      (if (list? li)
        (bind binding (head li)
          (if (list? binding)
            (if (symbol? (head binding))
              (self self (tail li))
              #f)
            #f))
        #f)))
    (env?-r env?-r li))))