#lang racket (define (prefix-list op L) ; the prefixes are stacked so need to be reversed to get into ; proper order (reverse (foldl (lambda (e p) (if (null? p) ; base case is single element e from head of ; list remaining to be processed (list e) ; p is a stack of prefixes, most recent on top ; so e is added on right of top of stack, and ; then pushed on (cons (op (first p) e) p) )) ; starting case of foldl, list to process '() L)) ) (prefix-list + '(0 1 2 3 4 5))