# Make a list continuous! [duplicate]

Take an input list L containing positive integers, and insert the least amount of integers into the sequence, so that you make it a continuous one.

### Example:

L = 4 2 6 1
Out: 4 3 2 3 4 5 6 5 4 3 2 1


The input and output formats are optional.

### Test cases:

L = 1
Out: 1

L = 10 4
Out: 10 9 8 7 6 5 4

L = 13 13
Out: 13 13

L = 3 6
Out: 3 4 5 6

L = 4 4 1 1 4 4
Out: 4 4 3 2 1 1 2 3 4 4


This is ... You know the rules.

• I'm almost certain this is a duplicate but I can't find the challenge… – Fatalize Oct 6 '17 at 9:18
• Related – Fatalize Oct 6 '17 at 9:20
• I tried finding a similar one myself, but I couldn't find any. I thought it would make a nice simple challenge. My favorite language is a bit messy when it comes to creating ranges in both ascending and descending order at the same time. – CG. Oct 6 '17 at 9:21
• @Fatalize I didn't find that one when I searched. I do feel this is different enough, but I don't know how strict the community is when it comes to similar challenges...? I guess there will be some answers that are easily portable though... – CG. Oct 6 '17 at 9:24
• Test case: [4,4,1,1,4,4] – Zgarb Oct 6 '17 at 9:29

# Builtin

### Husk:

…


Try it online!

I bet this builtin exists in more than one language, so I made this a community wiki, just add in more languages where this is a builtin if you know them!

# Brachylog, 11 bytes

⊆.s₂ᵇ-ᵐ~ṡᵐ∧


Try it online!

It's long and slow but at least it's declarative…

### Explanation

⊆.        ∧       The Input is an ordered subset of the Output
s₂ᵇ             Take all substring of 2 consecutive elements in the Output
-ᵐ           Take the subtractions of all those substrings
~ṡᵐ        They must all be valid "ṡigns" (i.e 1, 0 or -1)


# Mathematica, 72 bytes

Another approach using ReplaceAll.

#//.{(p={a___,b_,c_,d___})/;b>c+1->(f={a,b,b-#,c,d}&)@1,p/;b<c-1->f@-1}&