optional and default arguments in cm 3.8.0 scheme?

View: New views
3 Messages — Rating Filter:   Alert me  

optional and default arguments in cm 3.8.0 scheme?

by Michael Winkler-4 :: Rate this Message:

| View Threaded | Show Only this Message

hi list

I'm struggling with optional and default arguments: How can I do this
lisp code in schme common music?

(defun modl (list1 &optional (n 12))
   (loop for x in list1 collect (mod x n)))

examples:
(modl '(10 12 14))
 >> (10 0 2)
(modl '(10 12 14) 5)
 >> (0 2 4)

thankx and a happy new year
Michael

_______________________________________________
Cmdist mailing list
Cmdist@...
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist

Re: optional and default arguments in cm 3.8.0 scheme?

by joqu :: Rate this Message:

| View Threaded | Show Only this Message

use define*:

(define* (modl list1 (n 12))
 (loop for x in list1 collect (mod x n)))

best, johannes


Am 02.01.2012 um 22:22 schrieb Michael Winkler:

> hi list
>
> I'm struggling with optional and default arguments: How can I do this
> lisp code in schme common music?
>
> (defun modl (list1 &optional (n 12))
>  (loop for x in list1 collect (mod x n)))
>
> examples:
> (modl '(10 12 14))
>>> (10 0 2)
> (modl '(10 12 14) 5)
>>> (0 2 4)
>
> thankx and a happy new year
> Michael
>
> _______________________________________________
> Cmdist mailing list
> Cmdist@...
> http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist

_______________________________________________
Cmdist mailing list
Cmdist@...
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist

Re: optional and default arguments in cm 3.8.0 scheme?

by Heinrich Taube-2 :: Rate this Message:

| View Threaded | Show Only this Message

in addition to define* as johannes said, realize that many operators  
do their own mapping. for example in the latest sources you can use  
'mod' directly:

cm> (mod '(50 43 23) 12)
(2 7 11)

and of course for standard mod 12'ing of keynums you can always use 'pc'

cm> (pc '(50 43 23) )
(2 7 11)


On Jan 2, 2012, at 3:58 PM, Johannes Quint wrote:

> use define*:
>
> (define* (modl list1 (n 12))
> (loop for x in list1 collect (mod x n)))
>
> best, johannes
>

_______________________________________________
Cmdist mailing list
Cmdist@...
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist