class Campa::Lisp::Cons

Attributes

printer[R]

Public Class Methods

new() click to toggle source
# File lib/campa/lisp/cons.rb, line 4
def initialize
  @printer = Printer.new
end

Public Instance Methods

call(new_head, list) click to toggle source
# File lib/campa/lisp/cons.rb, line 8
def call(new_head, list)
  raise illegal_argument(list) if !list.is_a?(List)

  list.push(new_head)
end

Private Instance Methods

illegal_argument(list) click to toggle source
# File lib/campa/lisp/cons.rb, line 18
def illegal_argument(list)
  Error::IllegalArgument.new(printer.call(list), "list")
end