> Hello! > So far the nifty function of Prof Taube has worked fine with numbers: > However it seems it can't handle variables in the place of weights. > How can I change that so I can use for instance the command > (setq z 30) > (gn-weight 2 '((a z) (b 5) (c 50)))
hi. you can use a comma prefixed expression within the backquote macro (the ` char not the ' char) to selectively evaluate items in a list: so it would be: (let (( z 30)) (gn-weight 2 `((a , z) (b 5) (c 50)))) of course you can always use the list function and regular quoting to evaluate expressions too: (let ((z 30)) (gn-weight 2 (list (list 'a z) '(b 5) (c 50)))) but rather than using the code you included you might consider using patterns -- they will do all the work for you! in cm2 it would be (let (( z 30)) (new weighting :of `((a , z) (b 5) (c 50)))) in cm3: (let (( z 30)) (make-weighting `((a , z) (b 5) (c 50)) )) > _______________________________ > Cmdist mailing list > [email protected] > http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist _______________________________________________ Cmdist mailing list [email protected] http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist
