(archive 'newLISPer)

August 19, 2009

End of the rainbow

Filed under: newLISP — newlisper @ 17:39
Tags:

Not functional in the archive version.

If you use Safari, the following code may look intriguingly multi-coloured.

rainbow-code.png

 (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.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: