Sha256: d13333487db9b07b58465fa8573d3442c5e4ef927c27a2972fb9b1e4e212d20f
Contents?: true
Size: 673 Bytes
Versions: 3
Compression:
Stored size: 673 Bytes
Contents
module SXP class Pair attr_accessor :head attr_accessor :tail def initialize(head = nil, tail = nil) @head, @tail = head, tail end def inspect case when tail.nil? "(#{head.inspect})" else "(#{head.inspect} . #{tail.inspect})" end end def empty? head.nil? && tail.nil? end ## # @see http://srfi.schemers.org/srfi-1/srfi-1.html#ImproperLists def dotted? !proper? end ## # @see http://srfi.schemers.org/srfi-1/srfi-1.html#ImproperLists def proper? tail.nil? || tail.is_a?(Pair) end def to_a [head, tail] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sxp-0.0.3 | lib/sxp/pair.rb |
sxp-0.0.2 | lib/sxp/pair.rb |
sxp-0.0.1 | lib/sxp/pair.rb |