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 first defining variables and them into a list?
,@
, only,
; but to my mind the answer in both cases is essentially: "you're looking for backquote".quote
and not includeelisp
, IMO.)