Input Box for Chapter 5 and 6
function occurstar(a, l) { // return the # of a in l return isNull(l) ? 0 : isAtom(car(l)) ? isEq(car(l), a) ? add1(occurstar(a, cdr(l))) : occurstar(a, cdr(l)) : plus(occurstar(a, car(l)), occurstar(a, cdr(l))); } var s = str2sx("(a b c b d e bb f (b) g)"); sx2str(occurstar("b", s));
Output Box
It comes out here.