module SchemeLists
Scheme lists module
Public Instance Methods
car(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 113 def car(other) value = car_cdr_values other raise 'Cannot apply car on ' + other[0].to_s if value.nil? || value.empty? value.shift end
car_cdr_infinite(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 163 def car_cdr_infinite(other) fn = other[1] values = find_all_values other[2..-2] return call_car_cdr_infinite fn, values if @procs.key? fn.to_s raise arg_err_build 1, values.size unless values.size == 1 (generate_infinite_car_cdr fn).call values[0] end
cdr(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 119 def cdr(other) value = car_cdr_values other raise 'Cannot apply cdr on ' + other[0].to_s if value.nil? || value.empty? idx = value[1] == '.' ? 2 : 1 build_list value[idx..-1] end
cons(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 104 def cons(other) raise arg_err_build 2, other.size if other.size != 2 cons_helper other end
length(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 141 def length(other) (find_list_function_value other).size end
list(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 109 def list(other) build_list other end
list?(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 126 def list?(other) raise arg_err_build 1, other.size if other.size != 1 other[0].to_s.list? ? TRUE : FALSE end
map(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 150 def map(other) func, other = map_validate_helper other lst = find_all_values other lst = lst.map { |t| find_list_function_value [t] } lst = (equalize_lists lst).transpose build_list map_helper lst, func end
null?(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 136 def null?(other) raise arg_err_build 1, other.size if other.size != 1 other[0] == '\'()' ? TRUE : FALSE end
pair?(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 131 def pair?(other) raise arg_err_build 1, other.size if other.size != 1 other[0].to_s.pair? ? TRUE : FALSE end
reverse(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 145 def reverse(other) value = find_list_function_value other build_list value.reverse end
shuffle(other)
click to toggle source
# File lib/lisp/interpreter/core/list.rb, line 158 def shuffle(other) values = find_list_function_value other build_list values.shuffle end