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?
,@
, only,
; but to my mind the answer in both cases is essentially: "you're looking for backquote". – npostavs Mar 17 '19 at 13:08quote
and not includeelisp
, IMO.) – Drew Mar 17 '19 at 16:58