Welcome to the CHICKEN Scheme pasting service
custom flatten added by phasers_to_stun on Wed Jan 20 23:44:57 2016
define (flatten lst sym) (cond ((eq? lst '()) '()) ((list? (car lst)) (cond ((eq? (car lst) sym) (append (flatten (car lst) sym) (flatten (cdr lst) sym))) (else (cons (car lst) (flatten (cdr lst) sym))))) (else (cons (car lst) (flatten (cdr lst) sym))))) So the make-sum function will be re-written, I need this function to work though. ;This is what should happen: (flatten '(5 (+ 1 2) 3 4 (* 7 6)) '+) =>(5 + 1 2 3 4 (* 7 6)) ;This is what actually happens (flatten '(5 (+ 1 2) 3 4 (* 7 6)) '+) =>(5 (+ 1 2) 3 4 (* 7 6)) It should go in for each term in the list, and if the term is a list, check its operator, If the operator matches sym, then it will flatten the list out at that symbol