def rFilter(fn, arr)
  return [] if arr.empty?
  head, *tail = arr   
  if fn.call(head)
    return [head] + rFilter(fn, tail)
  end    
  rFilter(fn, tail)
end

numbers = [1, 2, 3, 4, 5]
p rFilter(->(x){ x.odd? }, numbers)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: