[plt-scheme] Re: Some fine distinctions
On May 13, 2:47 pm, Robby Findler <ro... at eecs.northwestern.edu> wrote:
> (but it is an arity error so maybe that doesn't count...)
>
Ach!!
fixed the arity error and the incorrect base case.
sumlists :: listoflists -> number
(define sumlists
(lambda (a-list)
(let sumlists ([a-list a-list] [accum 0])
(cond
[(empty? a-list) accum]
[(list? (first a-list)) (sumlists (rest a-list)
(+ accum (sumlists (first a-list))
0))]
[else (sumlists (rest a-list) (+ accum (first a-list)))]))))
So I repeat. It's not tail recursive and I don't see how it could be
made to be.
If I'm right about the first two, isn't one better off writing it
stack recursively.