 
 
 
 
 
 
 
  
The parallel function takes as its arguments a set, an operator, and possibly additional arguments. It applies the operator to the set in parallel, and returns the empty set. Parallel may be called for its side effects, or as a means of manipulating the set elements. This implementation of parallel is actually sequential, but it is an error to use parallel in a way which relies on a particulat order of evaluation.
(define parallel
  (function sset
            ((a sset) (b procedure) . c )
            (letrec
                ((internal-ordered
                  (lambda (vector index length)
                    (if (< index length)
                        (begin (apply
                                b
                                (cons
                                 a
                                 (cons (vector-ref vector index)
                                       (cons index c))))
                               (internal-ordered
                                vector (+ 1 index) length))
                        '())))
                 (internal-not
                  (lambda (elements operation)
                    (if (null? elements)
                        '()
                        (begin (apply operation
                                      (cons a (cons (car elements)
                                                    (cons -1 c))))
                               (internal-not (cdr elements) operation))))))
              (if (ordered? a) 
                  (internal-ordered
                   (cadr a) 0 (vector-length (cadr a)))
                  (internal-not (cdr a) b))
              '(set))))