Jump to content
Sign in to follow this  
AM

a simple lisp question

Recommended Posts

is it possible to do such a (nonsense-function) with mapcar (then with loop)?

-> how should i handle the &key (y 1) with mapcar? possible? a function without &key is clear but with &key ....???

 

thanx for a note

 

(defun testfu (value &key (y 1))
  (* (random 10) value y))

(loop 
  for i in '(1 2 3 4 5)
  for j in '(1 2 3 4 5)
  collect (testfu i :y j))

 

Share this post


Link to post
Share on other sites

(defun testfu (value &optional (y 1))
  (* (random 10) value y))

 

(mapcar #'testfu
        '(1 2 3 4 5)
        '(1 2 3 4 5))

 

I am not aware how you could handle a keyword directly by map car, but you can always turn the keyword argument into a plain argument in an intermediate function.

 

(defun testfu (value &key (y 1))
  (* (random 10) value y))

 

(mapcar #'(lambda (x y) (testfu x :y y))
        '(1 2 3 4 5)
        '(1 2 3 4 5))

 

Best,

Torsten

Share this post


Link to post
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.

Sign in to follow this  

  • Similar Topics

    • By AM
      LISP...
      any solution? i want to DIVIDE a seq into sublists -> when it's asc into a list, "rest"  into single-listed values - thanx a lot for some help 🙂
       
      ;;; input (divide* '(14 12 3 13 15 8 4 10 17 2 16 0 1 6 7 5 11 9)) ;;; output => ((14) (12) (3 13 15) (8) (4 10 17) (2 16) (0 1 6 7) (5 11) (9))  
    • By hujairi
      Hello,
       
      I am trying to find different ways of importing partials/frames data into Opusmodus. I am currently trying to use spectral analysis to analyzes certain music/audio phenomena I haven't really seen analyzed before to adapt into my own composition process. The sounds are generally archival or things I have synthesized on the computer through software myself (in .wav format), and are usually between 1 - 5 seconds in length. Is this a good length of time to analyze the spectral data of sounds? 
       
      I just wanted to understand the following information about spectral tools within Opusmodus. I really would appreciate it if anyone could help me out.
       
      1. Is it only Spear that we can use for spectral analysis? Is something like Audiosculpt also useable?
       
      2. Looking at Spear, when we explore the data, which of the following export formats do we use: 1. Text - Resampled Frames, 2. Text - Partials, 3. SDIF 1 TRC - Resampled Frames, 4. SDIF 1 TRC - Exact Interpolated, or 5. SDIF RBEP?
       
      3. Once I have the data in the correct format, I think I want to create a library of the datasets I important so that I can reinterpret them in the future. If I want to use the "get-tuning" function, for example, and then mapping it across certain instruments within my planned orchestration. What would be an effective way of doing this?
       
      One of my main challenges is finding a way to keep all my data organized every time I want to use Opusmodus for a new project. I still find myself using Opusmodus in little blocks as I compose, and I hope to eventually get to the point in which I can compose entire pieces using only Opusmodus. 
       
      I really appreciate your help.
    • By JulioHerrlein
      Dear All,
       
      I´m doing some melodic permutations and I have a question about replace-map:
      Here are four elements permutations, generated by:
      (permute '(1 2 3 4)) (setf permut4 '((1 2 3 4) (1 2 4 3) (1 3 2 4) (1 3 4 2) (1 4 2 3) (1 4 3 2) (2 1 3 4) (2 1 4 3) (2 3 1 4) (2 3 4 1) (2 4 1 3) (2 4 3 1) (3 1 2 4) (3 1 4 2) (3 2 1 4) (3 2 4 1) (3 4 1 2) (3 4 2 1) (4 1 2 3) (4 1 3 2) (4 2 1 3) (4 2 3 1) (4 3 1 2) (4 3 2 1))) Here are the pitch material to be permutated:
      (setf permutcontent '((1 cs4) (2 d4) (3 e4) (4 g4))) I used the REPLACE MAP FUNCTION, like this:
      (replace-map permutcontent permut4)  
      THE RESULT:
      ((c4 d4 e4 g4) (c4 d4 g4 e4) (c4 e4 d4 g4) (c4 e4 g4 d4) (c4 g4 d4 e4) (c4 g4 e4 d4) (d4 c4 e4 g4) (d4 c4 g4 e4) (d4 e4 c4 g4) (d4 e4 g4 c4) (d4 g4 c4 e4) (d4 g4 e4 c4) (e4 c4 d4 g4) (e4 c4 g4 d4) (e4 d4 c4 g4) (e4 d4 g4 c4) (e4 g4 c4 d4) (e4 g4 d4 c4) (g4 c4 d4 e4) (g4 c4 e4 d4) (g4 d4 c4 e4) (g4 d4 e4 c4) (g4 e4 c4 d4) (g4 e4 d4 c4))  
      THE QUESTION:
      What if I want to replace one item (like a pitch) for a list of melodic pitches ?
      How to proceed ?
       
      For example:
      Instead of substitute a C4 for the number 1, I want to substitute a list of notes, like (cs4 ds4)
      (setf permutcontent '((1 cs4 ds4) (2 d4) (3 e4) (4 g4)))  
      When I set this, a get only the cs4 permeated...
       
      Best,
      Julio
       
      I got it !
       
      All the material must have the same number of elements, like
      (setf permutcontent '((1 (c4 cs4)) (2 (b4 ds4)) (3 (c5 f4)) (4 (cs5 ds4))))  
      Resulting in:
      ((c4 cs4) (b4 ds4) (c5 f4) (cs5 ds4)) ((c4 cs4) (b4 ds4) (cs5 ds4) (c5 f4)) ((c4 cs4) (c5 f4) (b4 ds4) (cs5 ds4)) ((c4 cs4) (c5 f4) (cs5 ds4) (b4 ds4)) ((c4 cs4) (cs5 ds4) (b4 ds4) (c5 f4)) ((c4 cs4) (cs5 ds4) (c5 f4) (b4 ds4)) ((b4 ds4) (c4 cs4) (c5 f4) (cs5 ds4)) ((b4 ds4) (c4 cs4) (cs5 ds4) (c5 f4)) ((b4 ds4) (c5 f4) (c4 cs4) (cs5 ds4)) ((b4 ds4) (c5 f4) (cs5 ds4) (c4 cs4)) ((b4 ds4) (cs5 ds4) (c4 cs4) (c5 f4)) ((b4 ds4) (cs5 ds4) (c5 f4) (c4 cs4)) ((c5 f4) (c4 cs4) (b4 ds4) (cs5 ds4)) ((c5 f4) (c4 cs4) (cs5 ds4) (b4 ds4)) ((c5 f4) (b4 ds4) (c4 cs4) (cs5 ds4)) ((c5 f4) (b4 ds4) (cs5 ds4) (c4 cs4)) ((c5 f4) (cs5 ds4) (c4 cs4) (b4 ds4)) ((c5 f4) (cs5 ds4) (b4 ds4) (c4 cs4)) ((cs5 ds4) (c4 cs4) (b4 ds4) (c5 f4)) ((cs5 ds4) (c4 cs4) (c5 f4) (b4 ds4)) ((cs5 ds4) (b4 ds4) (c4 cs4) (c5 f4)) ((cs5 ds4) (b4 ds4) (c5 f4) (c4 cs4)) ((cs5 ds4) (c5 f4) (c4 cs4) (b4 ds4)) ((cs5 ds4) (c5 f4) (b4 ds4) (c4 cs4)))  
      But would be nice to MIX different number of elements...
×
×
  • Create New...