(use-modules (srfi srfi-1))

(define (run-with-err-handler code)
  (catch #t
		 (lambda () (get-retval-string (eval-string code)))
		 error-handler))

(define (error-handler key . params)
  (format #f "~A error: ~A" key (format #f (cadr params) (caddr params))))

(define (get-retval-string x)
  (with-output-to-string
	(lambda ()
	  (if (unspecified? x)
		'()
		(display x)))))

; (define fib-cycle '(nm-down nm-right nm-up nm-left))
;
;(define (fib n)
;  (if (<= n 2)
;	1
;  	(+
;		(fib (1- n))
;		(fib(- n 2))
;		)))

;(map
;  (lambda (x)
;	(primitive-eval `(,x))
;	(nm-flag)(nm-redraw))
;  (fold-right
;	append
;	'()(map(lambda(x)(apply make-list x))(map(lambda(x) `(,(fib (+ 2 x)) ,(list-ref fib-cycle (modulo x 4))))(iota 10)))))
