Class: Array

Inherits:
Object show all
Includes:
Callable
Defined in:
lib/array_extensions.rb

Instance Method Summary collapse

Methods included from Callable

#call, #call_as

Instance Method Details

#restObject Also known as: cdr

Lisp-style list access


3
4
5
# File 'lib/array_extensions.rb', line 3

def rest
  self[1 .. -1]
end

#to_list(recursive = false) ⇒ Object Also known as: sexp


10
11
12
13
14
15
16
17
18
# File 'lib/array_extensions.rb', line 10

def to_list(recursive = false)
  self[0] = first.sexp(recursive) if recursive

  if self.cdr.nil? or self.cdr.empty?
    BusScheme::Cons.new(car, nil)
  else
    BusScheme::Cons.new(car, self.cdr.sexp(recursive))
  end
end