Hey everyone,
Im completely new in the lisp world, and i was just doing some programming and would be very grateful to anyone who could help.
In a program i am writing i have one particular line which uses append and takes values such as:
(append '((1 (X 1) (X 1)) (1 (X 1) (Y 1))) '((1 (X 1) (X 1)) (1 (X 1) (Y 1))))
this gives:
((1 (X 1) (X 1)) (1 (X 1) (Y 1)) (1 (X 1) (X 1)) (1 (X 1) (Y 1)))
This is correct for my program, however what i want to do is change the append for a CONS to give the same final answer, however i am finding this increasingly difficult. Just wondering if there was a very simple way to do this.
Thank you in advance
Expressing an Append comman in Cons
Re: Expressing an Append comman in Cons
Append takes lists and returns a list with their contents concatenated.
nil is a list of length 0. (cons x nil) is a list of length 1. (cons x y) is a normal list if y is a normal list; it is a "dotted" list otherwise. Append does not accept dotted lists.
Maybe that helps? Otherwise, you will have to be more specific. For example, show a function call (including arguments) and the desired output. Showing your broken code is also recommended.
nil is a list of length 0. (cons x nil) is a list of length 1. (cons x y) is a normal list if y is a normal list; it is a "dotted" list otherwise. Append does not accept dotted lists.
Maybe that helps? Otherwise, you will have to be more specific. For example, show a function call (including arguments) and the desired output. Showing your broken code is also recommended.
Re: Expressing an Append comman in Cons
Cheers, thanks very much, that has helped.