How to write a list literal with conditional items? [duplicate]How to evaluate the variables before adding them to a list?Creating an association list with element evaluationHow to write assertionshow to access/print a list of a list?How to remove / delete nth element of a listWrapper objects / types for Emacs Lisp primitives?How to create and traverse a multidimensional listHow to wrap a single string literal across multiple lines?How do I rotate list elements?Adding many items to a listHow to delete all list elements matching a regexp?

Pre-Employment Background Check With Consent For Future Checks

What are rules for concealing thieves tools (or items in general)?

Norwegian Refugee travel document

Homology of the fiber

Does Shadow Sorcerer's Eyes of the Dark work on all magical darkness or just his/hers?

Acquisition - what happens to stock?

What is the tangent at a sharp point on a curve?

Can "few" be used as a subject? If so, what is the rule?

Hackerrank All Women's Codesprint 2019: Name the Product

Print a physical multiplication table

When should a starting writer get his own webpage?

Do native speakers use "ultima" and "proxima" frequently in spoken English?

pipe commands inside find -exec?

Align centered, ragged right and ragged left in align environment

10 year ban after applying for a UK student visa

How can a new country break out from a developed country without war?

How to remove space in section title at KOMA-Script

Why didn’t Eve recognize the little cockroach as a living organism?

Would this string work as string?

How to find the largest number(s) in a list of elements?

What is the difference between something being completely legal and being completely decriminalized?

Nested Dynamic SOQL Query

UK Tourist Visa- Enquiry

In the backstop position will the UK be able to negotiate FTAs?



How to write a list literal with conditional items? [duplicate]


How to evaluate the variables before adding them to a list?Creating an association list with element evaluationHow to write assertionshow to access/print a list of a list?How to remove / delete nth element of a listWrapper objects / types for Emacs Lisp primitives?How to create and traverse a multidimensional listHow to wrap a single string literal across multiple lines?How do I rotate list elements?Adding many items to a listHow to delete all list elements matching a regexp?













2
















This question already has an answer here:



  • How to evaluate the variables before adding them to a list?

    2 answers



Given a list literal '(1 2 3)



is it possible to conditionally include parts of the list?



eg:



'(1 2 3
(when thing-is-true '(10 11 12)))
4 5 6)


Which would result in



'(1 2 3 4 5 6) or '(1 2 3 10 11 12 4 5 6) dependent on thing-is-true.




Python for example supports:



[1, 2, 3, *([10, 11, 12] if thing_is_true else []), 4, 5, 6]



What is the most straightforward way to achieve this using a single expression, without defining a list variable and manipulating it?










share|improve this question















marked as duplicate by npostavs, DoMiNeLa10 yesterday


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Don't think this is a duplicate because I'm not asking about adding items to a list. Rather, how to declare a list. Also notice the answer to this question is quite different.

    – ideasman42
    yesterday











  • Hmm, I guess there is minor difference in that the dup's answer doesn't mention ,@, only ,; but to my mind the answer in both cases is essentially: "you're looking for backquote".

    – npostavs
    yesterday











  • I was aware of the feature (that it could be useful in this case), I just didn't know how to use it because I'm not that experienced in elisp.

    – ideasman42
    yesterday






  • 1





    I'm not aware of what you're aware of, I just talk about what's written in the question and vote accordingly.

    – npostavs
    yesterday











  • Seems like a dup to me, regardless of a minor difference in what you're trying to do. The question is really about a misunderstanding, and the referenced duplicate Q&A covers that. (And the tags should include quote and not include elisp, IMO.)

    – Drew
    yesterday















2
















This question already has an answer here:



  • How to evaluate the variables before adding them to a list?

    2 answers



Given a list literal '(1 2 3)



is it possible to conditionally include parts of the list?



eg:



'(1 2 3
(when thing-is-true '(10 11 12)))
4 5 6)


Which would result in



'(1 2 3 4 5 6) or '(1 2 3 10 11 12 4 5 6) dependent on thing-is-true.




Python for example supports:



[1, 2, 3, *([10, 11, 12] if thing_is_true else []), 4, 5, 6]



What is the most straightforward way to achieve this using a single expression, without defining a list variable and manipulating it?










share|improve this question















marked as duplicate by npostavs, DoMiNeLa10 yesterday


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Don't think this is a duplicate because I'm not asking about adding items to a list. Rather, how to declare a list. Also notice the answer to this question is quite different.

    – ideasman42
    yesterday











  • Hmm, I guess there is minor difference in that the dup's answer doesn't mention ,@, only ,; but to my mind the answer in both cases is essentially: "you're looking for backquote".

    – npostavs
    yesterday











  • I was aware of the feature (that it could be useful in this case), I just didn't know how to use it because I'm not that experienced in elisp.

    – ideasman42
    yesterday






  • 1





    I'm not aware of what you're aware of, I just talk about what's written in the question and vote accordingly.

    – npostavs
    yesterday











  • Seems like a dup to me, regardless of a minor difference in what you're trying to do. The question is really about a misunderstanding, and the referenced duplicate Q&A covers that. (And the tags should include quote and not include elisp, IMO.)

    – Drew
    yesterday













2












2








2









This question already has an answer here:



  • How to evaluate the variables before adding them to a list?

    2 answers



Given a list literal '(1 2 3)



is it possible to conditionally include parts of the list?



eg:



'(1 2 3
(when thing-is-true '(10 11 12)))
4 5 6)


Which would result in



'(1 2 3 4 5 6) or '(1 2 3 10 11 12 4 5 6) dependent on thing-is-true.




Python for example supports:



[1, 2, 3, *([10, 11, 12] if thing_is_true else []), 4, 5, 6]



What is the most straightforward way to achieve this using a single expression, without defining a list variable and manipulating it?










share|improve this question

















This question already has an answer here:



  • How to evaluate the variables before adding them to a list?

    2 answers



Given a list literal '(1 2 3)



is it possible to conditionally include parts of the list?



eg:



'(1 2 3
(when thing-is-true '(10 11 12)))
4 5 6)


Which would result in



'(1 2 3 4 5 6) or '(1 2 3 10 11 12 4 5 6) dependent on thing-is-true.




Python for example supports:



[1, 2, 3, *([10, 11, 12] if thing_is_true else []), 4, 5, 6]



What is the most straightforward way to achieve this using a single expression, without defining a list variable and manipulating it?





This question already has an answer here:



  • How to evaluate the variables before adding them to a list?

    2 answers







elisp list






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday







ideasman42

















asked yesterday









ideasman42ideasman42

1,555625




1,555625




marked as duplicate by npostavs, DoMiNeLa10 yesterday


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by npostavs, DoMiNeLa10 yesterday


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Don't think this is a duplicate because I'm not asking about adding items to a list. Rather, how to declare a list. Also notice the answer to this question is quite different.

    – ideasman42
    yesterday











  • Hmm, I guess there is minor difference in that the dup's answer doesn't mention ,@, only ,; but to my mind the answer in both cases is essentially: "you're looking for backquote".

    – npostavs
    yesterday











  • I was aware of the feature (that it could be useful in this case), I just didn't know how to use it because I'm not that experienced in elisp.

    – ideasman42
    yesterday






  • 1





    I'm not aware of what you're aware of, I just talk about what's written in the question and vote accordingly.

    – npostavs
    yesterday











  • Seems like a dup to me, regardless of a minor difference in what you're trying to do. The question is really about a misunderstanding, and the referenced duplicate Q&A covers that. (And the tags should include quote and not include elisp, IMO.)

    – Drew
    yesterday

















  • Don't think this is a duplicate because I'm not asking about adding items to a list. Rather, how to declare a list. Also notice the answer to this question is quite different.

    – ideasman42
    yesterday











  • Hmm, I guess there is minor difference in that the dup's answer doesn't mention ,@, only ,; but to my mind the answer in both cases is essentially: "you're looking for backquote".

    – npostavs
    yesterday











  • I was aware of the feature (that it could be useful in this case), I just didn't know how to use it because I'm not that experienced in elisp.

    – ideasman42
    yesterday






  • 1





    I'm not aware of what you're aware of, I just talk about what's written in the question and vote accordingly.

    – npostavs
    yesterday











  • Seems like a dup to me, regardless of a minor difference in what you're trying to do. The question is really about a misunderstanding, and the referenced duplicate Q&A covers that. (And the tags should include quote and not include elisp, IMO.)

    – Drew
    yesterday
















Don't think this is a duplicate because I'm not asking about adding items to a list. Rather, how to declare a list. Also notice the answer to this question is quite different.

– ideasman42
yesterday





Don't think this is a duplicate because I'm not asking about adding items to a list. Rather, how to declare a list. Also notice the answer to this question is quite different.

– ideasman42
yesterday













Hmm, I guess there is minor difference in that the dup's answer doesn't mention ,@, only ,; but to my mind the answer in both cases is essentially: "you're looking for backquote".

– npostavs
yesterday





Hmm, I guess there is minor difference in that the dup's answer doesn't mention ,@, only ,; but to my mind the answer in both cases is essentially: "you're looking for backquote".

– npostavs
yesterday













I was aware of the feature (that it could be useful in this case), I just didn't know how to use it because I'm not that experienced in elisp.

– ideasman42
yesterday





I was aware of the feature (that it could be useful in this case), I just didn't know how to use it because I'm not that experienced in elisp.

– ideasman42
yesterday




1




1





I'm not aware of what you're aware of, I just talk about what's written in the question and vote accordingly.

– npostavs
yesterday





I'm not aware of what you're aware of, I just talk about what's written in the question and vote accordingly.

– npostavs
yesterday













Seems like a dup to me, regardless of a minor difference in what you're trying to do. The question is really about a misunderstanding, and the referenced duplicate Q&A covers that. (And the tags should include quote and not include elisp, IMO.)

– Drew
yesterday





Seems like a dup to me, regardless of a minor difference in what you're trying to do. The question is really about a misunderstanding, and the referenced duplicate Q&A covers that. (And the tags should include quote and not include elisp, IMO.)

– Drew
yesterday










1 Answer
1






active

oldest

votes


















2














You can use the macro (elisp) Backquote, e.g.,



`(1 2 3 ,@(when nil '(10 11 12)) 4 5 6)
;; => (1 2 3 4 5 6)

`(1 2 3 ,@(when t '(10 11 12)) 4 5 6)
;; => (1 2 3 10 11 12 4 5 6)


if you expand the above macros, they are simply using append



(append '(1 2 3) (when nil '(10 11 12)) '(4 5 6))
;; => (1 2 3 4 5 6)

(append '(1 2 3) (when t '(10 11 12)) '(4 5 6))
;; => (1 2 3 10 11 12 4 5 6)





share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    You can use the macro (elisp) Backquote, e.g.,



    `(1 2 3 ,@(when nil '(10 11 12)) 4 5 6)
    ;; => (1 2 3 4 5 6)

    `(1 2 3 ,@(when t '(10 11 12)) 4 5 6)
    ;; => (1 2 3 10 11 12 4 5 6)


    if you expand the above macros, they are simply using append



    (append '(1 2 3) (when nil '(10 11 12)) '(4 5 6))
    ;; => (1 2 3 4 5 6)

    (append '(1 2 3) (when t '(10 11 12)) '(4 5 6))
    ;; => (1 2 3 10 11 12 4 5 6)





    share|improve this answer



























      2














      You can use the macro (elisp) Backquote, e.g.,



      `(1 2 3 ,@(when nil '(10 11 12)) 4 5 6)
      ;; => (1 2 3 4 5 6)

      `(1 2 3 ,@(when t '(10 11 12)) 4 5 6)
      ;; => (1 2 3 10 11 12 4 5 6)


      if you expand the above macros, they are simply using append



      (append '(1 2 3) (when nil '(10 11 12)) '(4 5 6))
      ;; => (1 2 3 4 5 6)

      (append '(1 2 3) (when t '(10 11 12)) '(4 5 6))
      ;; => (1 2 3 10 11 12 4 5 6)





      share|improve this answer

























        2












        2








        2







        You can use the macro (elisp) Backquote, e.g.,



        `(1 2 3 ,@(when nil '(10 11 12)) 4 5 6)
        ;; => (1 2 3 4 5 6)

        `(1 2 3 ,@(when t '(10 11 12)) 4 5 6)
        ;; => (1 2 3 10 11 12 4 5 6)


        if you expand the above macros, they are simply using append



        (append '(1 2 3) (when nil '(10 11 12)) '(4 5 6))
        ;; => (1 2 3 4 5 6)

        (append '(1 2 3) (when t '(10 11 12)) '(4 5 6))
        ;; => (1 2 3 10 11 12 4 5 6)





        share|improve this answer













        You can use the macro (elisp) Backquote, e.g.,



        `(1 2 3 ,@(when nil '(10 11 12)) 4 5 6)
        ;; => (1 2 3 4 5 6)

        `(1 2 3 ,@(when t '(10 11 12)) 4 5 6)
        ;; => (1 2 3 10 11 12 4 5 6)


        if you expand the above macros, they are simply using append



        (append '(1 2 3) (when nil '(10 11 12)) '(4 5 6))
        ;; => (1 2 3 4 5 6)

        (append '(1 2 3) (when t '(10 11 12)) '(4 5 6))
        ;; => (1 2 3 10 11 12 4 5 6)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        xuchunyangxuchunyang

        8,8941926




        8,8941926













            Popular posts from this blog

            He _____ here since 1970 . Answer needed [closed]What does “since he was so high” mean?Meaning of “catch birds for”?How do I ensure “since” takes the meaning I want?“Who cares here” meaningWhat does “right round toward” mean?the time tense (had now been detected)What does the phrase “ring around the roses” mean here?Correct usage of “visited upon”Meaning of “foiled rail sabotage bid”It was the third time I had gone to Rome or It is the third time I had been to Rome

            Bunad

            Færeyskur hestur Heimild | Tengill | Tilvísanir | LeiðsagnarvalRossið - síða um færeyska hrossið á færeyskuGott ár hjá færeyska hestinum