Problem: how can I write a function that receives a
and b
as inputs and returns all integers inbetween them. So, assuming we have a function called integers_inbetween
that behaves like this, we should expect the following examples:
# Returns an array of integers in between a and b
integers_inbetween(1, 4)
[1] 2 3
and
# Returns an array of integers in between a and b
integers_inbetween(4, 1)
[1] 2 3
And
# Returns NULL if there are no integers inbetween a and b
integers_inbetween(3.5, 4)
[1] NULL
How can one implement that logic in R?