Class: Campa::Lisp::Cadr

Inherits:
Object
  • Object
show all
Defined in:
lib/campa/lisp/cadr.rb

Instance Method Summary collapse

Constructor Details

#initializeCadr

Returns a new instance of Cadr.



4
5
6
7
8
# File 'lib/campa/lisp/cadr.rb', line 4

def initialize
  @printer = Printer.new
  @car = Car.new
  @cdr = Cdr.new
end

Instance Method Details

#call(operation, list) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/campa/lisp/cadr.rb', line 14

def call(operation, list)
  return nil if list.nil? || list == List::EMPTY
  raise illegal_argument(list) if !list.is_a?(List)

  cut_list(
    list,
    operation
      .label[1..-2]
      .reverse
      .split("")
  )
end

#macro?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/campa/lisp/cadr.rb', line 10

def macro?
  true
end