Skip to content

Commit

Permalink
ruby.2: fix (rest (list 6))
Browse files Browse the repository at this point in the history
  • Loading branch information
asarhaddon authored and kanaka committed Aug 6, 2024
1 parent 2253ce6 commit 448d26a
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions impls/ruby.2/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,20 @@ def ns
end,

Types::Symbol.for("rest") => Types::Builtin.new("rest") do |list_or_vector|
if !list_or_vector.nil? && list_or_vector != Types::Nil.instance
result = list_or_vector[1..]

if result.nil?
result = Types::List.new
Types::List.new (
case list_or_vector
when Types::List, Types::Vector
if list_or_vector.empty?
[]
else
list_or_vector[1..]
end
when Types::Nil
[]
else
raise TypeError, "Unable to `rest`, too nervous"
end

result.to_list
else
Types::List.new
end
)
end,

Types::Symbol.for("throw") => Types::Builtin.new("throw") do |to_throw|
Expand Down Expand Up @@ -369,7 +372,7 @@ def ns

Types::Symbol.for("sequential?") => Types::Builtin.new("sequential?") do |list_or_vector|
case list_or_vector
when Types::List, Types::Vector
when Types::List, Types::Vector
Types::True.instance
else
Types::False.instance
Expand Down

0 comments on commit 448d26a

Please sign in to comment.