Jump to content

LISP Defun Question


Avner Dorman

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!

 

 

 

Link to comment
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!!!

Link to comment
Share on other sites

  • 1 year later...

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy