Class: Campa::Lisp::Cond
- Inherits:
-
Object
- Object
- Campa::Lisp::Cond
- Defined in:
- lib/campa/lisp/cond.rb
Constant Summary collapse
- FALSEY =
[false, nil].freeze
Instance Method Summary collapse
- #call(*conditions, env:) ⇒ Object
-
#initialize ⇒ Cond
constructor
A new instance of Cond.
- #macro? ⇒ Boolean
Constructor Details
Instance Method Details
#call(*conditions, env:) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/campa/lisp/cond.rb', line 15 def call(*conditions, env:) found = conditions.find do |cond| raise illegal_argument(cond) if !cond.is_a?(List) !FALSEY.include? evaler.call(cond.head, env) end eval_result(found, env) end |
#macro? ⇒ Boolean
11 12 13 |
# File 'lib/campa/lisp/cond.rb', line 11 def macro? true end |