cas2xtm   xtlang


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

Implementation

(bind-func cas2xtm
  (lambda (e:String*)
    (beginz
     (if (regex_match "^list\\[.*\\]$" e)
         (set! e (substring e 4 (length e))))
     (if (regex_match "^\\[.*\\]$" e)
         (let ((p (regex_split "," (substring e 1 (- (length e) 1)))))
           (cat (Str "(vector") (concat (map (lambda (x) (cat (Str " ") (cas2xtm x))) p)) (Str ")")))
         (let ((res1 (multi_replace_all (concat (cas_parse_terms e))
                                        (list
                                         (list (Str "plus") (Str "+"))
                                         (list (Str "neg") (Str "* -1.0:double"))
                                         (list (Str "pi") (Str "PI")))))
               (res (cat (Str "(+ 0.0:double ")
                         res1
                         (Str ")"))))
           res)))))


Back to Index

Similar Entries