--- /dev/null
+(in-package :parenscript)
+
+;;; Script of library functions you can include with your own code to
+;;; provide standard Lisp functionality.
+
+(defparameter *ps-lisp-library*
+ '((defun mapcar (fun &rest as)
+ (let ((result-array (make-array)))
+ (if (= 1 (length as))
+ (dolist (element (aref as 0))
+ (result-array.push (fun element)))
+ (dotimes (i (length (aref as 0)))
+ (let ((args-array (mapcar (lambda (a) (return (aref a i))) as)))
+ (result-array.push (fun.apply fun args-array)))))
+ (return result-array)))))
(defpsmacro ignore-errors (&body body)
`(try (progn ,@body) (:catch (e))))
+;;; Data structures
+
+(defpsmacro length (a)
+ `(.size ,a))
+
;;; Misc
(defpsmacro null (x)
`(= ,x nil))
+
+(defpsmacro @ (obj &rest props)
+ "Handy slot-value/aref composition macro."
+ (if (null props)
+ obj
+ `(@ (slot-value
+ ,(if (stringp obj) `($ ,obj) obj)
+ ,(let ((prop (macroexpand (first props))))
+ (if (symbolp prop)
+ `',prop
+ prop)))
+ ,@(cdr props))))
\ No newline at end of file