LISP код на сайте

Посмотрим как справляется плагин WP-Syntax с исходниками на LISP.

(defun rsubs (old new form)
	(cond
		((atom form) (if (equal form old) new form))
		((equal form old) new)
		(t (loop for el in form collect (rsubs old new el)))
	)
)

(defun rrem (what form)
	(cond
		((atom form) (if (equal what form) nil form))
		(t (loop for el in form 
			if (not (equal what el))
			collect (if (listp el) (rrem what el) el)
		))
	)
)

(defun rins (where what form &key before)
	(cond 
		((atom form) form)
		(t (loop for el in form append 
			(if (equal el where) 
				(if before (list what el) (list el what))
				(if (listp el) 
					(list (rins where what el :before before))
					(list el)
				)
			)
		))
	)
)

3 thoughts on “LISP код на сайте

Добавить комментарий