I have 2 dynamic lists that I would like to merge into one.
Say
'(1 2 3 4)
and
'(15 16)
and get
'(1 2 3 4 15 16)
How can this be done?
The append function joins two lists together to make one. The append function is built into Scheme. It concatenates two lists, that is to say, given two lists list1 and list2 it produces a new list which starts with the same elements as list1 and finishes with those of list2 .
Pairs and Lists in The Racket Guide introduces pairs and lists. A pair combines exactly two values. The first value is accessed with the car procedure, and the second value is accessed with the cdr procedure. Pairs are not mutable (but see Mutable Pairs and Lists).
Use append
for this:
(append '(1 2 3 4) '(15 16))
=> '(1 2 3 4 15 16)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With