Module: Nydp::Helper

Instance Method Summary collapse

Instance Method Details

#cons(a, b = Nydp.NIL) ⇒ Object



11
12
13
# File 'lib/nydp/helper.rb', line 11

def cons a, b=Nydp.NIL
  Nydp::Pair.new a, b
end

#list(*args) ⇒ Object



15
16
17
# File 'lib/nydp/helper.rb', line 15

def list *args
  Nydp::Pair.from_list args
end

#literal?(expr) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
# File 'lib/nydp/helper.rb', line 23

def literal? expr
  case expr
  when String, Float, Integer, Fixnum, Nydp.NIL, Nydp::Symbol, Nydp::StringAtom, Nydp::Truth, Nydp::Nil
    true
  else
    false
  end
end

#pair?(expr) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/nydp/helper.rb', line 7

def pair? expr
  expr.is_a?(Nydp::Pair)
end

#sym(name, ns) ⇒ Object



19
20
21
# File 'lib/nydp/helper.rb', line 19

def sym name, ns
  Nydp::Symbol.mk name, ns
end

#sym?(expr, name) ⇒ Boolean

Returns:

  • (Boolean)


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

def sym? expr, name
  expr.is_a?(Nydp::Symbol) && (expr.is? name)
end