On Jan 5, 2009, at 7:18 AM, Michael Haupt wrote:

(syntax LIST (lambda (node compiler)
    `[OrderedCollection withAll: ,@[node copyFrom: '1]]))

The trouble seems to be that ,@ expands all collection items in place, instead of providing a collection again. #withAll:, however, obviously expects a collection.

How should the syntax definition look?

Does this do anything like what you need?

(define map1
  (lambda (fn list)
    (let ((result [OrderedCollection new])
          (index  '1)
          (limit  [list size]))
      (while [index < limit]
        [result addLast: (fn [list at: index])]
        (set index [index + '1]))
      result)))

(define LIST-append
  (lambda (expr)
    `[_ addLast: ,expr]))

(syntax LIST
  (lambda (node compiler)
    `(let ((_ [OrderedCollection new]))
       ,@(map1 LIST-append node)
       _)))

(We know the size of the final result, so could use an Array and at:put: instead of an OrderedCollection.)

Cheers,
Ian


_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc

Reply via email to