[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Trying to write a scheme function
From: |
dfro |
Subject: |
Trying to write a scheme function |
Date: |
Thu, 3 Nov 2022 20:18:44 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 |
Hello everyone,
I would like to create a function that transforms one note to another
using scheme's cond procedure. This is what I have working so far using
an arg of type number?:
%start code
\version "2.22.2"
tNote =
#(define-scheme-function
(note)
(number?)
(_i "Transform one note to another using cond")
(cond ((= note 1) #{ { c } #})
((= note 2) #{ { c' } #})
((= note 3) #{ { c''2 } #})
(else #{ s #})
)
)
{ \tNote 1 \tNote 5 \tNote 2 \tNote 3 }
%end code
_________
I want the type to be ly:music? and the cond procedure to evaluate a
note rather than a number. The following code does not work (I get an
'Unbound variable" error), but I think it shows what I am trying to do:
%start code
\version "2.22.2"
tNote =
#(define-scheme-function
(note)
(ly:music?)
(_i "Transform one note to another using cond")
(cond ((= note c,) #{ { c } #})
((= note d,) #{ { c' } #})
((= note e,2) #{ { c''2 } #})
(else #{ s #})
)
)
{ \tNote c, \tNote f \tNote d, \tNote e,2 }
%end code
_________
Should I be creating a music function rather than a scheme function?
Any thoughts on how to get this working and why it works? Thanks for any
help and for the mailing list.
Peace,
David
- Trying to write a scheme function,
dfro <=