Re: [racket-users] recursive function with multiple arguments

2019-04-12 Thread Matthias Felleisen
A bit of modernity yields this: (define (project-pop.v1 y r k thetasd t [i 1]) (cond [(= i t) (list y)] [else (define theta (flvector-ref (flnormal-sample 0.0 thetasd 1) 0)) (define y1 (* y (- r (* r (/ y k))) (exp theta))) (cons y (project-pop y1 r k thetasd t (+ i

Re: [racket-users] recursive function with multiple arguments

2019-04-11 Thread David Storrs
Others have already given elegant solutions, but if you'd like a simple transliteration that does not require a struct, here you go: #lang racket (require math) (define (logmod y r k thetasd) (define theta (flvector-ref (flnormal-sample 0.0 thetasd 1) 0)) (list (* y (- r (* r (/ y

Re: [racket-users] recursive function with multiple arguments

2019-04-11 Thread Matt Jadud
Hi Travis, Others will probably have better insights. The only part that would be able to be replaced with a recursive call in logmodr seems to be the loop itself. It is walking the list/vector y from the second element to t (which... does numeric on a vector coerce it to a length? I have no idea

[racket-users] recursive function with multiple arguments

2019-04-10 Thread travis . hinkelman
Hi All, I'm trying to better understand recursion. I decided to rewrite the logmodr function from this blog post as a recursive function. I was easily able to write the recursive functions if all but one of the arguments w