I think I found a solution to my drum'n'bass idea using only functions, but I'm having a little trouble with one function. (and I started a new thread because I am no longer talking about macros)
Basically, one way of thinking of drum'n'bass beats is as a concatenation of rhythmic fragments.
I'm representing each fragment with a list that will become part of set to be played by ```playobs```
so if I concatenate this fragment ```'(0 1/2)``` with this fragment ```'(0 1/4)``` I want to get a temporal recursion like this:
```(define playloop
(lambda (beat dur)
(playobs (list 0 1/2 2/2 5/4) 2 drums 10 80 dur)
(callback (*metro* (+ beat (* .5 dur))) 'playloop (+ beat dur) dur)))
(playloop (*metro* 'get-beat 4) 1/4)```
so I created two functions to do the first part of this:
```(define inc-frag
(lambda (frag inc)
(if (null? frag)
'()
(cons (+ (car frag) inc)
(inc-frag (cdr frag) inc)))))
(define assemble-frags
(lambda (frags inc)
(if (null? frags)
'()
(cons (inc-frag (car frags) inc)
(assemble-frags (cdr frags) (+ inc 1))))))```
so ```(assemble-frags ('(0 1/2) '(0 1/2) '(0 1/4)) 0)``` should return the set ```'(0 1/2 2/2 3/2 4/2 9/4)```
inc-frag gives the correct results, but assemble-frags only returns the last element of the input list (0 1/4) and seems to set extempore into an infinite loop.
The function seems to make sense, but when I change the null condition from '() to '(1) I still get (0 1/4) as an answer, which makes me wonder if the function ever makes it to the null condition. But if not, how does it return anything at all? Next I tried,
```(define assemble-frags
(lambda (frags inc)
(if (null? frags)
'()
(begin (cons (inc-frag (car frags) inc)
(assemble-frags (cdr frags) (+ inc 1)))
(println "test")))))```
And still, I only get (0 1/4) in the console.
Anyone have an idea what I'm doing wrong?
Thanks!
Jason