I need to generate a sequence like this:  

`[1, 3, 5, 7, 9, 13, 17, 21, 25, 31, 37, 43, 49, 57, 65, 73, 81]`

(17 numbers in this example)

The algorithm is:  

`[1, (previous + 2), (previous + 2), (previous + 2), (previous + 2), (previous + 4), (previous + 4), (previous + 4), (previous + 4) ...`

So it's +2 for 4 first items, then +4 for next 4, then +6 for next 4. Increment is increased by 2 each four items.

I was able to do a quick and hacky version in Ruby:

```
def sequence
  incr = 0
  (0..16).each.inject([]) do |acc, counter|
    acc << (acc.last || 1) + incr
    incr += 2 if counter.modulo(4) == 0
    acc
  end
end

```

But I am having problems doing the same in Elixir - it turns out super-lame. Like this: 

```
def sequence do
  { sequence, _ } =
    0..16
    |> Enum.reduce({[], 0}, fn(counter, {result, incr}) ->
      last = List.last(result)
      if last do
        result = result ++ [last + incr]
      else
        result = [1]
      end
      if rem(counter, 4) == 0 do
        incr = incr + 2
      end
      {result, incr}
    end)
  sequence
end

```

Obviously I should not be thinking imperatively here, but for this problem I can't :D
I am also sure there is an approach where pipes are much more atomic.

How can this problem be solved in an Elixir way?