Jump to content

Featured Replies

Posted

I'm stuck. Why does the first example work but not the second? Thanks!

(setf v1 '((-w h a4 d4)
           (h f4 e4 d4 q a4 g4)
           (q f4 g4 e a4 bb4 c5 a4 q bb4 h a4 q g4)
           (h a4 bb4 w a4)))

First example:

(loop for n from 1 to 4
      collect
        (get-events '(1 2 (2..4)) v1)) ;; "works"

Second example:

(loop for n from 1 to 4
      collect
        (get-events '(1 n (2..4)) v1)) ;; doesn't work, why?

This is the error message:

Error: In 1- of (n) arguments should be of type number.
  1 (continue) Return a value to use.
  2 Supply a new argument.
  3 (abort) Return to top loop level 0.

 

(loop for n from 1 to 4
      collect
        (get-events (list 1 n '(2..4)) v1))

 

Jesper

  • Author

Thanks Jesper, works like a charm! 🤩

;;asign 3 variables a, b, and c to 1, 2 and 3

(setf a 1 b 2 c 3)

(list a b c)
=>(1 2 3)

'(a b c)
=>(a b c)
 

Jesper

Yes, but macros and backquote are a bit harder to understand.

 

Jesper

 

 

29 minutes ago, jesele said:

Yes, but macros and backquote are a bit harder to understand.

 

Jesper

 

 

indeed, you are right. I agree for macros but this simple example of use of backquotes list and comma to evaluate is not too difficult I think and very elegant.

Create an account or sign in to comment


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy