How to use INSERT clause in MAP?

Anders Vinjar cmdist@ccrma.Stanford.EDU
12 Dec 1997 12:14:24 +0100


>>>>> "lt" == Larry Troxler <lt@westnet.com> writes:

    lt> Well without further adieu, here's the problem I'm having. I
    lt> can't get "insert" to work at all, and "insert-at" sort of seems
    lt> to work after emitting an error message:

This seems like a bug to me.  There are a couple of places in 'map.lisp'
which might be leftovers from a revision of some kind.  Until Rick or
someone has time to look at this you can use the diff included below.
The fix works for the time being. My transcript shows:

Stella [Vamp3]: list
Vamp3:
     1. #<MIDI-NOTE | E3|   1/4|   1/4| 0.100| 0|> 
     2. #<MIDI-NOTE | F3|   1/4|   1/4| 0.100| 0|> 
     3. #<MIDI-NOTE | G3|     0|   3/4| 0.100| 0|> 
     4. #<MIDI-NOTE | A3|     0|   3/4| 0.100| 0|> 

Stella [Vamp3]: map 2:3 insert (make-object rest)
New objects Vamp3[2,4]
Stella [Vamp3]: list
Vamp3:
     1. #<MIDI-NOTE | E3|   1/4|   1/4| 0.100| 0|> 
     2. #<REST unset#x108a82fa> 
     3. #<MIDI-NOTE | F3|   1/4|   1/4| 0.100| 0|> 
     4. #<REST unset#x108a8352> 
     5. #<MIDI-NOTE | G3|     0|   3/4| 0.100| 0|> 
     6. #<MIDI-NOTE | A3|     0|   3/4| 0.100| 0|> 

Stella [Vamp3]: map 5:6 insert-at @ (make-object rest)
New objects Vamp3[5,7]
Stella [Vamp3]: list
Vamp3:
     1. #<MIDI-NOTE | E3|   1/4|   1/4| 0.100| 0|> 
     2. #<REST unset#x108a82fa> 
     3. #<MIDI-NOTE | F3|   1/4|   1/4| 0.100| 0|> 
     4. #<REST unset#x108a8352> 
     5. #<REST unset#x108aa40a> 
     6. #<MIDI-NOTE | G3|     0|   3/4| 0.100| 0|> 
     7. #<REST unset#x108aa482> 
     8. #<MIDI-NOTE | A3|     0|   3/4| 0.100| 0|> 



Heres the output from the diff:

*** /tmp/map.lispa005gD	Fri Dec 12 12:04:52 1997
--- /tmp/map.lisp~a005gD	Fri Dec 12 12:04:52 1997
***************
*** 779,790 ****
              (push (list #'print-find-result op expr count cache width) 
                    *map-results*))
             ((:insert :append :insert-at :append-at)
!             (loop with sort = (when (consp (clause-forms clause))
! 				(> (length (clause-forms clause)) 2))
                    and container 
                    for additions in (nreverse cache)
                    do
! 	      (setf container (pop additions))
                ;; we process the (position . object) specs in additions 
                ;; in decending order.
                (when additions
--- 779,789 ----
              (push (list #'print-find-result op expr count cache width) 
                    *map-results*))
             ((:insert :append :insert-at :append-at)
!             (loop with sort = (> (length (clause-forms clause)) 2)
                    and container 
                    for additions in (nreverse cache)
                    do
!               (setf container (pop additions))
                ;; we process the (position . object) specs in additions 
                ;; in decending order.
                (when additions
***************
*** 801,807 ****
                                    do (incf off (if (consp (cdr x)) 
                                                     (length (cdr x)) 
                                                   1)))))
! 		  (print-external-references *standard-output* container nums 0))))))))
        (:analyze
         (setf *expr-length* 
           (max *expr-length* (length (clause-external clause))))
--- 800,806 ----
                                    do (incf off (if (consp (cdr x)) 
                                                     (length (cdr x)) 
                                                   1)))))
!                   (print-external-references container nums 0 nil))))))))
        (:analyze
         (setf *expr-length* 
           (max *expr-length* (length (clause-external clause))))