End of the rainbow
If you use Safari, the following code may look intriguingly multi-coloured.
(define (add-columns table-name new-column-list (value nil))
;; @syntax (add-columns table-name new-column-list value)
;; Add more columns to table (and every row in table).
;; You can provide a default value for them.
;; (add-columns 'elements '(Price Postage) 0)
(letex ((table table-name))
(let ((columns (first table)))
; mustn't duplicate columns
(if (empty? (intersect new-column-list columns))
(setf table
(cons (append columns new-column-list)
(map (fn (r)
(append r (dup value (length new-column-list))))
(rest table))))))))
Let me know if you can work out what's going on, and what you think.

0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home