Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions app/server/ruby/lib/sonicpi/lang/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1772,20 +1772,24 @@ def spread(num_accents, size, *args)


def range(start, finish, *args)
start = start.to_f
finish = finish.to_f
if is_list_like?(args) && args.size == 1 && args.first.is_a?(Numeric)
# Allow one optional arg for legacy reasons. Versions earlier
# than v2.5 allowed: range(1, 10, 2)
step_size = args.first
inclusive = false
else
args_h = resolve_synth_opts_hash_or_array(args)
step_size = args_h[:step] || 1.0
step_size = step_size.to_f
step_size = args_h[:step] || 1
inclusive = args_h[:inclusive]
end

# If all args are ints, return ints
unless start.is_a? Integer and finish.is_a? Integer and step_size.is_a? Integer then
start = start.to_f
finish = finish.to_f
step_size = step_size.to_f
end

return [].ring if start == finish

raise ArgumentError, "step size: opt for fn range should be a non-zero number" unless step_size != 0
Expand Down