scmcas   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/contrib/cas.xtm

Implementation

(define (scmcas name e . args)
  (let* ((a (cas-xtm-to-string `(,name ,e ,@args)))
         (b (regex:replace-all a "}" "\)"))
         (c (regex:replace-all b "{" "\("))            
         (xx (cptr->string (casppoff c)))
         (res1 (cptr->string (cas2xtm_scm xx)))
         (res2 (regex:replace-all res1 "([0-9]*)\\.0*\\:double" "$1"))
         (res3 (regex:replace-all res2 "\\:double" "0"))
         (res (string->sexpr res2)))
    (println 'cas: a 'sexpr: res1 'result: res)
    (if (equal? (car res) 'vector)
        (cons 'vector
              (map (lambda (x)
                     (if (= (length x) 3)
                         (caddr x)
                         (if (> (length x) 3)
                             (cons '+ (cddr x))
                             x)))
                   (cdr res)))
        (if (= (length res) 3)
            (caddr res)
            (if (> (length res) 3)
                (cons '+ (cddr res))
                res)))))


Back to Index