g | x | w | all
Bytes Lang Time Link
004MathGolf241105T154631ZKevin Cr
045AWK241105T152425Zxrs
004Uiua241105T032042Znyxbird
002Thunno 2230611T164933ZThe Thon
044Elm230128T192915ZKirill L
021Zsh230127T163707Zroblogic
nan230127T165853ZThe Thon
006Japt180723T161254ZShaggy
031Arturo230127T073535Zchunes
nan221013T035532Zbigyihsu
003Vyxal221013T032326ZDialFros
032Excel210508T125636ZAxuary
018Julia210508T122247ZMarcMush
019Jellyfish210508T103544ZRazetime
005Jelly210508T081507ZUnrelate
019Factor210508T050804Zchunes
010Brachylog180724T134057ZSundar R
016C gcc180725T191425Zuser7740
010K oK180725T055526Zmkst
007Recursiva180725T050459Z0xffcour
094Lua180725T033354ZVisckmar
030Kotlin180724T124835ZYGolybev
052Scala180724T111622ZV. Court
050C++180724T110753ZToby Spe
003Husk170925T181139Zბიმო
017J170925T180032ZAlex Shr
012Kona/K4170925T180756ZAlex Shr
041Common Lisp170921T151835ZRenzo
0338th170721T223214ZChaos Ma
032Java OpenJDK 8170627T155716ZOlivier
095C++170626T144110ZSteadybo
081C++170628T023828ZTas
018Perl 6170627T203911ZSean
008V170626T151450ZDJMcMayh
046C++170626T181542Zrahnema1
026Clojure170627T151258ZMattPutn
033LOGO170627T112259Zuser2027
007Japt170626T142213ZTom
021Braingolf170627T085734ZMayube
006MATL170627T085141ZSanchise
039F#170627T084020Zuser2015
010MATL170627T082956ZStewie G
017Ruby170627T073007ZG B
082Java 8170626T150537ZKevin Cr
005APL Dyalog170627T035334ZTwiN
004Pyth170627T013457Zisaacg
033Racket170626T221203Zuser6325
005NewStack170626T215145ZGraviton
030R170626T143715ZGiuseppe
405TIS100170626T160031Zjunkmail
028Clojure170626T162517ZNikoNyrh
012q/kdb170626T160035Zmkst
008CJam170626T152746ZLuis Men
060BrainFlak170626T153222ZDJMcMayh
019tcl170626T152847Zsergiol
029Rust170626T151946ZCensored
029Haskell170626T142212ZHenry
027JavaScript ES6170626T151853ZNeil
062C#170626T150827ZTheLetha
005Pyth170626T150334ZFryAmThe
059PHP>=7.1170626T150212ZJör
007APL Dyalog170626T145606Zuser4180
003Neim170626T145320ZErik the
054C# .NET Core170626T144333ZCharlie
016Dyalog APL170626T143643ZUriel
021Perl 5170626T142952ZDada
00605AB1E170626T142248ZRiley
005Jelly170626T142836ZErik the
020Octave170626T142650Zrahnema1
026Python170626T142101Zovs
017Mathematica170626T141516ZZaMoC

MathGolf, 4 bytes

\É≥x

First input is the list; second input is a pair \$[x,y]\$.

Try it online.

Explanation:

\     # Swap the two (implicit) input-lists, so both are on the stack
 É    # For-each over the pair, using two characters as inner code-block:
  ≥   #  Remove that many leading items from the list
   x  #  Reverse the list
      # (after the loop, the entire stack is output implicitly as result)

AWK, 45 bytes

{for(i=$(NF-1)+1;i<NF-$NF-1;i++)printf $i" "}

This one works on TIO (64 bytes):

BEGIN{FPAT="[0-9]"}{for(i=$(NF-1)+1;i<NF-$NF-1;i++)printf $i" "}

Try it online!

This has better formatting (92 bytes):

BEGIN{FPAT="[0-9]"}{x=NF-$NF-1;s="[";for(i=$(NF-1)+1;i<x;i++)s=s$i (i==x-1?"]":" ");print s}

Uiua, 4 bytes

↘¯:↘

Try it!

Takes input as x a y. ↘ drop x from a, : flip a and y, and ↘ drop ¯ negative y from a (negative numbers drop from the back).

Thunno 2, 2 bytes

ỵẓ

Attempt This Online!

Input in the order \$a, l, b\$, where \$a\$ is the number of items to remove from the front, \$b\$ is the number of items to remove from the back, and \$l\$ is the list.

Explanation

ỵẓ  # Implicit input
ỵ   # Remove from front
 ẓ  # Remove from back
    # Implicit output

Elm, 44 bytes

h x=List.reverse<<List.drop x
f x y=h y<<h x

Try it on Ellie

Zsh, 21 bytes

<<<${@:2+$1:-1-$@[#]}

Try it online!

Input format: x <array> y

Thunno, \$5\log_{256}(96)\approx\$ 4.12 bytes

ZxsZy

Attempt This Online!

Takes x then the array then y

Explanation

Zx     # Remove the first x elements from the array
  s    # Swap so y is now on the top of the stack
   Zy  # Remove the last y elements from the array
       # Implicit output

Japt, 6 bytes

oW UsV

Try it

sVWnUl

Try it

oW UsV     :Implicit input of array U and integers V=x & W=y
oW         :Remove the last W elements of U, mutating the original
   UsV     :Slice U from 0-based index V
sVWnUÊ     :Implicit input of array U and integers V=x & W=y
sV         :Slice U from 0-based index V to index
  Wn       :  Subtract W from
    UÊ     :  Length of U

Arturo, 31 bytes

$[a,x,y][slice a x(size a)-y+1]

Try it

Go, 49 bytes, ints only

func f(t[]int,x,y int)[]int{return t[x:len(t)-y]}

Attempt This Online!

Go, 52 bytes, generic

func f[T any](t[]T,x,y int)[]T{return t[x:len(t)-y]}

Attempt This Online!

Vyxal, 3 bytes

N"i

Try it Online!

Excel, 32 bytes

=OFFSET(A1,B1,,COUNT(A:A)-B1-C1)

Link the Spreadsheet

The array is entered in column A starting at A1.

Julia, 18 bytes

a*b*c=a[1+b:end-c]

Try it online!

Jellyfish, 19 bytes

p
vvj
 -0
 j
 0
j
0

Try it online!

Takes input as

y
array
x

via STDIN.

This program translates to:

p    (v   (j         (0),v   (-    (0,j         (0)),j         (0)))
print(drop(eval_input(0),drop(minus(0,eval_input(0)),eval_input(0)))

Jelly, 5 bytes

‘ṫṚ¥ƒ

Try it online!

Takes [x, y] on the left and the list on the right. Ties the existing Jelly answer, but I'm posting it anyways because:

‘        Increment x and y.
    ƒ    With the list as the initial value of the accumulator, reduce [x, y] by:
 ṫ       remove the first (right - 1) elements from the accumulator,
  Ṛ¥     then reverse it.

Factor, 19 bytes

[ head* swap tail ]

Try it online!

Takes input as x sequence y.

Brachylog, 11 10 bytes

kb₍B&t;Bk₍

Try it online!

Takes input as [x, A, y] where A is the array to trim.

(-1 byte thanks to @Fatalize.)

C (gcc), 16 bytes

The compiler instruction:

-DX(a,x,y)=(a+x)

As most would know, an array in C is just a known length and a pointer to the beginning of an array. Thus, we get an array with x members removed from the left and y members removed from the right by just moving the pointer to the array by +x.

Try it online!

K (oK), 10 bytes

{(-z)_y_x}

Try it online!

Port of my q/kdb+ answer...

Recursiva, 7 bytes

Zba-Lac

Try it online!

Lua, 94 bytes

n,s=loadstring('return{},'..p[1])()for x=1,#s do n[#n+1]=x>0+p[2]and#s>=x+p[3]and s[x]or _ end

Try it online!

If I used something that I couldn't please tell me.

Explanation

p = {...} -- (Header) It gets the 3 arguments (the list and the 2 numbers and stores in a table)


n,s=loadstring('return{},'..p[1])() -- is the same as (i) and (ii):
 (i) n = {} -- initializes an empty table
(ii) s = loadstring('return '..p[1])() -- makes the string '{1,2,3}' become a table with 3 elements (1, 2 and 3)

for x=1,#s do -- from 1 to the number of elements in s, repeat:
  n[#n+1] = x>0+p[2] and #s>=x+p[3] and s[x] or _
  n[#n+1]   -- append to n
              0+p[2]   -- convert "2" to the number 2
            x>0+p[2] and #s>=x+p[3]   -- if we're past the start limit and before the end limit
                                    and s[x]   -- then the element to be appended is the one with index x of the original list
                                             or _   -- else append nil (the same as doing nothing)
end


print(table.concat(n, ", ")) -- (Footer) print the elements of n separated by commas

I used _ as nil just to be a little bit more clear (although this is not the point of these answers hahah). I could've used any variable that wasn't previously declared. _ doesn't have anything special in Lua.
And the comparisons are really messy because I tried to organize the math in a way that special characters would help me to use less space. ... and a>#b uses 1 more byte than ... and#b>a.

If you have any questions ask and I'll try to answer them.

Kotlin, 30 bytes

{a,s,e->a.drop(s).dropLast(e)}

Try it online!

Takes List<Int> as input and drops from begin and then from end.

Scala, 52 bytes

def f(a:Seq[Int],c:Int,d:Int)=a.dropRight(d).drop(c)

Try it online!

C++, 50 bytes

[](auto&v,int x,int y){v={v.begin()+x,v.end()-y};}

Just construct a new container from the existing one. This requires v to be of a type with random-access iterators and constructible from an iterator pair - std::vector is ideally suited.

Demo

auto const trim =
    [](auto&v,int x,int y){v={v.begin()+x,v.end()-y};}
    ;

#include<iostream>
#include<vector>
int main(int argc, char **argv)
{
    if (argc < 4) {
        std::cerr << "Usage: " << argv[0] << " X Y ELE...";
        return 1;
    }

    auto const x = std::atoi(argv[1]);
    auto const y = std::atoi(argv[2]);
    std::vector<int> v;
    v.reserve(argc - 3);
    for (int i = 3;  i < argc;  ++i)
        v.push_back(std::atoi(argv[i]));

    auto const print_vector = [](auto v){for(auto i:v)std::cout<<i<<" ";std::cout<<'\n';};

    print_vector(v);
    trim(v, x, y);
    print_vector(v);
}

Husk, 3 bytes

↓↓_

Try it online!

Explanation

                                               |  1 [1,2,3,4,5,6] 2
  _  -- negate y                               | -1 [1,2,3,4,5,6] 2
 ↓   -- drop y from end (negative argument)    |  [1,2,3,4,5] 2
↓    -- drop x from beginning                  |  [3,4,5]

J, 17 bytes

(-@{:@[}.{.@[}.])

Usage:

   2 1 (-@{:@[}.{.@[}.]) 11 12 13 14 15 16
13 14 15

Kona/K4, 12 bytes

{x _(-y)_ z}

Usage:

   {x _(-y)_ z}[2;1;"hello world"]
"llo worl"

Common Lisp, 41 bytes

(lambda(a x y)(subseq a x(-(length a)y)))

Try it online!

8th, 33 bytes

Code

This code leaves resulting array on TOS

( a:rev swap -1 a:slice ) 2 times

Usage

ok> 2 1 [1,2,3,4,5] ( a:rev swap -1 a:slice ) 2 times .
[3,4]
ok> 5 0 [6,2,4,3,5,1,3] ( a:rev swap -1 a:slice ) 2 times .
[1,3]
ok> 
ok> 0 0 [1,2] ( a:rev swap -1 a:slice ) 2 times .
[1,2]
ok>

Java (OpenJDK 8), 32 bytes

(l,i,j)->l.subList(i,l.size()-j)

Try it online!

If we really restrict to arrays, then it's 53 bytes:

(a,i,j)->java.util.Arrays.copyOfRange(a,i,a.length-j)

Try it online!

C++, 96 95 bytes

Thanks to @Tas for saving a byte!

#import<list>
int f(std::list<int>&l,int x,int y){for(l.resize(l.size()-y);x--;)l.pop_front();}

Try it online!

C++ (MinGW), 91 bytes

#import<list>
f(std::list<int>&l,int x,int y){for(l.resize(l.size()-y);x--;)l.pop_front();}

C++, 81 bytes

#include<vector>
int f(std::vector<int>&v,int x,int y){v={v.begin()+x,v.end()-y};}

Not as short as this use of a macro.

std::vector provides random access, and we simply create a new vector from the start point v.begin() + x, to the new end point v.end() - y elements.

Uses the iterator overload v.begin() and v.end() since it's the same length as the pointer one &v[0] and &*(v.end()), but more readable.

Function doesn't return an int like it promises, which is only a compiler warning.

Perl 6, 18 bytes

{@^a[$^x..^*-$^y]}

@^a is the input array (first parameter), $^x is the number of elements to remove from the front (second parameter), and $^y is the number of elements to remove from the end (third parameter).

$^x ..^ *-$^y is a slicing subscript that selects a range of elements from the one with index $^x until one prior to the one with index *-$^y (* meaning "the length of the array" in a subscript context).

V, 9 8 bytes

ÀñdñGÀñd

Try it online!

One byte saved thanks to Erik the golfer!

C++, 50 48 46 bytes

#define f(a,x,y)decltype(a)(&a[x],&*a.end()-y)

Try it online!

Clojure, 26 bytes

#(drop %2(drop-last %3 %))

LOGO, 33 bytes

[cascade ?2 "bf cascade ?3 "bl ?]

Try it on FMSLogo.

This is a template-list in LOGO, which is the equivalent of lambda (anonymous) function in many other languages.

Where:

Test:

show apply [cascade ?2 "bf cascade ?3 "bl ?] [[1 2 3 4 5 6] 2 1]

print [3 4 5].

Japt, 8 7 bytes

sVUl -W

Try it online!

Saved a byte thanks to ETHproductions

Braingolf, 22 21 bytes

1-<1-[v$_R][v<$_R]v=;

Try it online!

MATL, 6 bytes

QJi-h)

Try it online!

Input is given as 1) number of elements to trim from the start; 2) number of elements to trim from the end; 3) array. Explanation

Q   % Implicit input (1). Increment by 1, since MATL indexing is 1-based.
Ji- % Complex 1i minus real input (2). In MATL, the end of the array is given by `1i`.
h   % Concatenate indices to get range-based indexing 1+(1):end-(2).
)   % Index into (implicitly taken) input array. Implicit display.

F#, 39 bytes

let f(i:int[])s e=i.[s..(i.Length-1-e)]

Try it online!

MATL, 10 bytes

tniQwi-&:)

Try it online!

Explanation:

It's a bit long for just 11 bytes, but I'm writing it out in detail, to learn it myself too.

---- Input ----
[1 2 3 4 5 6]
2
1
----- Code ----
           % Implicit first input
t          % Duplicate input.
           % Stack: [1 2 3 4 5 6], [1 2 3 4 5 6]
 n         % Number of elements
           % Stack: [1 2 3 4 5 6], 6
  i        % Second input
           % Stack: [1 2 3 4 5 6], 6, 2
   Q       % Increment: [1 2 3 4 5 6], 6, 3
    w      % Swap last two elements
           % Stack: [1 2 3 4 5 6], 3, 6
     i     % Third input
           % Stack: [1 2 3 4 5 6], 3, 6, 1
      -    % Subtract
           % Stack: [1 2 3 4 5 6], 3, 5
       &:  % Range with two input arguments, [3 4 5]
           % Stack: [1 2 3 4 5 6], [3 4 5]
         ) % Use as index
           % Stack: [3 4 5]
           % Implicit display

Ruby, 17 bytes

->a,b,c{a[b..~c]}

Try it online!

Java 8, 82 bytes

a->n->m->{int l=a.length-m-n,r[]=new int[l];System.arraycopy(a,n,r,0,l);return r;}

Try it here.

Alternative with same (82) byte-count using a loop:

(a,n,m)->{int l=a.length-m,r[]=new int[l-n],i=0;for(;n<l;r[i++]=a[n++]);return r;}

Try it here.

Explanation:

a->n->m->{                      // Method with integer-array and two integer parameters and integer-array return-type
  int l=a.length-m-n,           //  Length of the array minus the two integers
      r[]=new int[l];           //  Result integer-array
  System.arraycopy(a,n,r,0,l);  //  Java built-in to copy part of an array to another array
  return r;                     //  Return result-String
}                               // End of method

System.arraycopy:

arraycopy(Object src, int srcPos, Object dest, int destPos, int length):

The java.lang.System.arraycopy() method copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array. A subsequence of array components are copied from the source array referenced by src to the destination array referenced by dest. The number of components copied is equal to the length argument.

The components at positions srcPos through srcPos + length - 1 in the source array are copied into positions destPos through destPos + length - 1, respectively, of the destination array.

APL (Dyalog), 5 bytes

(⌽↓)/

Try it online!


Input format is y x A

Explanation

/ is Reduce, which inserts the function to the left between each pair of elements of the argument

(⌽↓) is a function train equivalent to {⌽⍺↓⍵}, which removes the first elements of the array and then reverses the array. ( is the left argument and is the right argument)

Thus, (⌽↓)/y x A is equivalent to ⌽y↓⌽x↓A, which is what is needed.

Pyth, 4 bytes

<E>E

Demonstration

Put the list last.

Racket, 33 bytes

(λ(a i j)(drop-right(drop a i)j))

It can be called like so:

((λ(a i j)(drop-right(drop a i)j)) '(1 2 3 4 5 6) 2 1)

NewStack, 5 bytes

ᵢqᵢpᵢ

The symmetry is an amazing coincidence

The breakdown:

ᵢ      Append an input (the array).
 qᵢ    Pop off an input's amount off the bottom.
   pᵢ  Pop off an input's amount off the top.

R, 32 31 30 bytes

-1 byte thanks to Rift

-1 byte thanks to Jarko Dubbeldam

pryr::f(n[(1+l):(sum(n|1)-r)])

Evaluates to an anonymous function:

function (l, n, r) 
    n[(1 + l):(sum(n|1) - r)]

1+l is necessary since R has 1-based indexing. sum(n|1) is equivalent to length(n) but it's a byte shorter.

Try it online!

TIS-100, 413 405 Bytes

472 cycles, 5 nodes, 35 lines of code

m4,6
@0
MOV 0 ANY
S:MOV UP ACC
JEZ A
MOV ACC ANY
JMP S
A:MOV RIGHT ACC
L:JEZ B
MOV DOWN NIL
SUB 1
JMP L
B:MOV 0 RIGHT
MOV RIGHT NIL
@1
MOV RIGHT LEFT
MOV LEFT DOWN
MOV RIGHT DOWN
MOV DOWN LEFT
@2
MOV UP ACC
MOV UP LEFT
MOV ACC LEFT
@4
MOV 0 RIGHT
MOV UP NIL
S:MOV LEFT ACC
JEZ A
MOV ACC RIGHT
JMP S
A:MOV UP ACC
L:JEZ B
MOV RIGHT NIL
SUB 1
JMP L
B:MOV 0 UP
K:MOV RIGHT ACC
MOV ACC DOWN
JNZ K
@7
MOV UP ANY

The m4,6 at the top is not part of the code, but signals the placement of the memory modules.

enter image description here

Play this level yourself by pasting this into the game:


function get_name()
    return "ARRAY TRIMMER"
end
function get_description()
    return { "RECIEVE AN ARRAY FROM IN.A", "RECIEVE TWO VALUES A THEN B FROM IN.T", "REMOVE THE FIRST A TERMS AND LAST B TERMS FROM IN.A", "ARRAYS ARE 0 TERMINATED" }
end

function get_streams()
    input = {}
    trim = {}
    output = {}

  arrayLengths = {}

    a = math.random(1,5) - 3

    b = math.random(1,7) - 4

    arrayLengths[1] = 9+a
    arrayLengths[2] = 9+b
    arrayLengths[3] = 8-a
    arrayLengths[4] = 9-b

    s = 0

    trimIndex = 1

  for i = 1,4 do
      for k = 1,arrayLengths[i] do
          x = math.random(1,999)
      input[k+s] = x
            output[k+s] = x
        end

        input[s + arrayLengths[i] + 1]= 0
        output[s + arrayLengths[i] + 1]= 0

        a = math.random(0,3)
        b = math.random(0,arrayLengths[i]-a)

        trim[trimIndex] = a
        trim[trimIndex+1] = b

        trimIndex = trimIndex + 2

    s = s + arrayLengths[i] + 1
    end

    s = 1
    trimIndex = 1

    for i = 1,4 do

      for i = s,s+trim[trimIndex]-1 do
          output[i]=-99
        end

        for i = s + arrayLengths[i] - trim[trimIndex+1], s + arrayLengths[i]-1 do
      output[i]=-99
        end

  trimIndex = trimIndex +2
  s = s + arrayLengths[i] + 1
    end

    trimmedOut = {}
    for i = 1,39 do
            if(output[i] ~= -99) then
                    table.insert(trimmedOut, output[i])
            end
    end

    return {
        { STREAM_INPUT, "IN.A", 0, input },
        { STREAM_INPUT, "IN.T", 2, trim },
        { STREAM_OUTPUT, "OUT.A", 1, trimmedOut },
    }
end
function get_layout()
    return {
        TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,
        TILE_MEMORY,    TILE_COMPUTE,    TILE_MEMORY,   TILE_COMPUTE,
        TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,
    }
end

So I suppose this also counts as a lua answer...

Clojure, 28 bytes

#(subvec % %2(-(count %)%3))

Well there is the built-in.

q/kdb, 12 bytes

Solution:

{(0-z)_y _x}

Example:

q){(0-z)_y _x}[1 2 3 4 5 6;2;1]
3 4 5
q){(0-z)_y _x}[6 2 4 3 5 1 3;5;0]
1 3
q){(0-z)_y _x}[1 2;0;0]
1 2

Explanation:

{          } / lambda function
          x  / input array
       y _   / drop y elements from .. (takes from start)
 (0-z)       / negative z ()
      _      / drop -z elements from ... (takes from end)

CJam, 8 bytes

{_,@-<>}

Anonymous block that takes the inputs from the stack in the order x, y, array, and replaces them by the output array.

Try it online!

Explanation

Consider inputs 2, 1, [10 20 30 40 50 60].

{      }    e# Block
            e# STACK: 2, 1, [10 20 30 40 50 60]
 _          e# Duplicate
            e# STACK: 2, 1, [10 20 30 40 50 60], [10 20 30 40 50 60]
  ,         e# Length
            e# STACK: 2, 1, [10 20 30 40 50 60], 6
   @        e# Rotate
            e# STACK: 2, [10 20 30 40 50 60], 6, 1
    -       e# Subtract
            e# STACK: 2, [10 20 30 40 50 60], 5
     <      e# Slice before
            e# STACK: 2, [10 20 30 40 50]
      >     e# Slice after
            e# STACK: [30 40 50]

Brain-Flak, 60 bytes

(()()){({}<{({}<{}>[()])}{}([]){{}({}<>)<>([])}{}<>>[()])}{}

Try it online!

Input is in this format:

x

a
r
r
a
y

y

Where x is the number to take from the front, y is the number to take from the back, and the array is just however many numbers you want, separated by newlines. Here are my first two (longer) attempts:

({}<>)<>{({}<{}>[()])}([])<>({}<><{{}({}<>)<>([])}{}><>){({}<{}>[()])}{}([]){{}({}<>)<>([])}<>{}
{({}<{}>[()])}{}([]){{}({}<>)<>([])}{}<>{({}<{}>[()])}{}([]){{}({}<>)<>([])}<>

And here is an explanation:

#Two times:
(()()){({}<

    #Remove *n* numbers from the top of the stack
    {({}<{}>[()])}{}

    #Reverse the whole stack
    ([]){{}({}<>)<>([])}{}<>

>)[()]}{}

tcl, 19

lrange $L $x end-$y

where L is the array.

demo

Rust, 29 bytes

|n,i,j|&n[i..<[_]>::len(n)-j]

Call it as follows:

let a = &[1, 2, 3, 4, 5, 6];
let f = |n,i,j|&n[i..<[_]>::len(n)-j];
f(a, 2, 1)

I had a lot of fun fighting with the borrow checker figuring out what the shortest approach was in order to have it infer the lifetime of a returned slice. Its behavior around closures is somewhat erratic, as it will infer the lifetimes, but only if you do not actually declare the parameter as a reference type. Unfortunately this conflicts with being required to define the argument type in the signature as the n.len method call needs to know the type it's operating on.

Other approaches I tried working around this issue:

fn f<T>(n:&[T],i:usize,j:usize)->&[T]{&n[i..n.len()-j]}     // full function, elided lifetimes
let f:for<'a>fn(&'a[_],_,_)->&'a[_]=|n,i,j|&n[i..n.len()-j] // type annotation only for lifetimes. Currently in beta.
|n:&[_],i,j|n[i..n.len()-j].to_vec()                        // returns an owned value
|n,i,j|&(n as&[_])[i..(n as&[_]).len()-j]                   // casts to determine the type
|n,i,j|&(n:&[_])[i..n.len()-j]                              // type ascription (unstable feature)
|n,i,j|{let b:&[_]=n;&b[i..b.len()-j]}                      // re-assignment to declare the type

Haskell, 55 39 33 29 bytes

Saved 16 bytes thanks to Laikoni

Saved 6 more bytes thanks to Laikoni

Saved 4 more bytes thanks to Laikoni

Am sure this could be improved, but as a beginner, gave it my best shot.

r=(reverse.).drop
a#b=r b.r a

Usage

(5#0) [6,5,4,3,2,1,3]

Try it online!

JavaScript (ES6), 27 bytes

(a,n,m)=>a.slice(n,-m||1/m)

A negative second parameter to slice stops slicing m from the end, however when m is zero we have to pass a placeholder (Infinity here, although (a,n,m,o)=>a.slice(n,-m||o) also works).

C#, 62 bytes

using System.Linq;(l,x,y)=>l.Where((n,i)=>i>=x&i<=l.Count-y-1)

Takes a List<int> as input and returns an IEnumerable<int>.


This also works for 64 bytes:

using System.Linq;(l,x,y)=>l.Skip(x).Reverse().Skip(y).Reverse()

Pyth, 5 bytes

>E<QE

Try it here

Takes the arguments in the opposite order. < and > in Pyth trim based on argument order. For example, <Q5 will trim off all values in the input after the fifth one.

PHP>=7.1, 59 bytes

<?[$a,$b,$e]=$_GET;print_r(array_slice($a,$b,$e?-$e:NULL));

PHP Sandbox Online

APL (Dyalog), 8 7 bytes

⌽⎕↓⌽⎕↓⎕

Try it online!

This takes the array as the first input, followed by the two numbers separately.

Explanation

⎕            from the input array
⎕↓           drop the first input elements
⌽            reverse the array
⎕↓           drop first input elements
⌽            reverse again to go back to the original array

Neim, 3 bytes

𝕘₃𝕙

Try it here

Thanks to Okx for encouraging me to do this...:)

C# (.NET Core), 55 54 bytes

using System.Linq;(a,x,y)=>a.Skip(x).Take(a.Count-x-y)

Try it online!

Uses a List<int> as input.

Dyalog APL, 16 bytes

{(⍵↓⍨⊃⍺)↓⍨-⍺[2]}

Try it online!

Perl 5, 21 bytes

19 bytes of code + -ap flags.

$_="@F[<>..$#F-<>]"

Try it online!

Uses -a to autosplit the input inside @F, then only keep a slice of it according to the other inputs: from index <> (second input) to index $#F-<> (size of the array minus third input). And $_ is implicitly printed thanks to -p flag.

05AB1E, 6 bytes

F¦}sF¨

Try it online!

F }    # For 0 .. number of elements to remove from front
 ¦     #   Remove the first element
   s   # Get the next input
    F  # For 0 .. number of elements to remove from back
     ¨ #   Remove the last element

Jelly, 5 bytes

Ṗ¡Ḋ⁴¡

Try it online!

Octave, 20 bytes

@(a,x,y)a(x+1:end-y)

Try it online!

Python, 28 26 bytes

-2 bytes thanks to @Rod

lambda a,n,m:a[n:len(a)-m]

Try it online!

Mathematica, 17 bytes

#[[#2+1;;-#3-1]]&

input

[{1, 2, 3, 4, 5, 6}, 2, 1]