
((wrap (vau root_env (quote)
((wrap (vau (let1)
(let1 lambda (vau se (p b1) (wrap (eval (array vau p b1) se)))
(let1 current-env (vau de () de)
(let1 cons (lambda (h t) (concat (array h) t))
(let1 Y (lambda (f3)
    ((lambda (x1) (x1 x1))
     (lambda (x2) (f3 (lambda (& y) (lapply (x2 x2) y))))))
(let1 vY (lambda (f)
    ((lambda (x3) (x3 x3))
     (lambda (x4) (f (vau de1 (& y) (vapply (x4 x4) y de1))))))
(let1 let (vY (lambda (recurse) (vau de2 (vs b) (cond (= (len vs) 0) (eval b de2)
                                                     true           (vapply let1 (array (idx vs 0) (idx vs 1) (array recurse (slice vs 2 -1) b)) de2)))))
 (let (
         rec-lambda (vau se (n p b) (eval (array Y (array lambda (array n) (array lambda p b))) se))

         palindrome (rec-lambda palindrome (s) (let (
                                                  ; _ (log "palindrome called")
                                                  length (- (len s) 1) ; -1 because we don't care about \n chars
                                                  ; _ (log "length is" (str length))
                                                 ) (cond (= length 0)   true
                                                         (= length 1)   true
                                                         true           (let (
                                                                              ; _ (log "getting first + last chars")
                                                                              first (idx s 0)
                                                                              last (idx s (- length 1)) 
                                                                              ; _ (log "Checking chars")
                                                                              ; _ (log first " == " last)
                                                                        )(cond (!= first last)  false
                                                                               true             (palindrome (slice s 1 -2)))
                                                                        )
                                                    )))
        palindrome_wrap (lambda (s) (cond (palindrome s) (concat "TRUE! " s " is a palindrome!!\n")
                                          true           (concat "FALSE! " s " is not a palindrome!!\n")))
         
                
         monad  (array 'write  1 "enter string to check if it is a palindrome: " (vau (written code)
                  (array 'read 0 60 (vau (s code)
                    (array 'write 1 (palindrome_wrap s) (vau (written code)
                            (array 'exit 0)
                     ))))))
 ) monad)
; end of all lets
))))))
; impl of let1
)) (vau de (s v b) (eval (array (array wrap (array vau (array s) b)) v) de)))
; impl of quote
)) (vau (x5) x5))
