Jump to content
Avner Dorman

LISP Defun Question

Recommended Posts

I have a basic lisp question - I'd like to create a function that takes a tonality as its argument and performs something like the following line: 

 

(setf test (tonality-map '((pcs '3-2) :root b3 :map shift) (make-scale 'c4 12)))

 

So (defun pitches (tonality) .....) - and then (pitches (pcs '3-2)) would return the list (b3 c4 d4 b4 c5 d5 b5 c6 d6 b6 c7 d7)

 

Thanks so much!

 

 

 

Share this post


Link to post
Share on other sites

The return is what you are looking for:

(tonality-map '((pcs '3-2) :root b3 :map shift) (make-scale 'c4 12))
=> (b3 c4 d4 b4 c5 d5 b5 c6 d6 b6 c7 d7)

or I don't understand you question :smile:

Share this post


Link to post
Share on other sites

Sorry if I am not clear - yes the return is what I want. Now I'd like to have a new function that only accepts the collection and returns this same notes.  

 

So (newfunction (pcs '3-2)) gives the same result.

 

These are obviously wrong - 

(defun newfunction (tonality)
  (tonality-map '((tonality) :root b3 :map shift) (make-scale 'c4 12)))

 

(defun newfunction (tonality)
  (tonality-map '(tonality :root b3 :map shift) (make-scale 'c4 12)))

 

My goal is to create more complex functions that make use of tonality-map - I realize this might seem unneeded in this simple example - but as the code gets complex I think this function would be helpful for me. 

 

Many Thanks!!!

Share this post


Link to post
Share on other sites

Works here:

(defun tmap (tonality)
  (tonality-map `(,tonality :root b3 :map step) (make-scale 'c4 12)))
  
(tmap (pcs '3-2))
=> (b3 c4 d4 b4 c5 d5 b5 c6 d6 b6 c7 d7)

 

added 3 minutes later

If you are getting an error you need to provide the expression otherwise I can't help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×