0

Is there any x such that:

x :: List(n) == List(n)

or

x :: List(n, n + 1, n + 2) == List(n, n + 1, n + 2)

I thought Nil would do this, but it doesn't. It seems to work when I do:

n :: Nil

or

List(n, n + 1, n + 2) :: Nil

but I need it the other way around.

user3685285
  • 6,066
  • 13
  • 54
  • 95

1 Answers1

4

You want the ::: or ++ operator, which will concatenate two lists:

Nil ::: List(n)
Nil ++ List(n)

Andrey helpfully points out that the ++ operator is more generic, so check out this link that he provided in his comment.

Tim
  • 26,753
  • 2
  • 16
  • 29