mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Fixed erroneous assertion in list_range()
This commit is contained in:
parent
c419ff93c8
commit
c05b6bfa5c
3 changed files with 3 additions and 2 deletions
|
@ -139,7 +139,7 @@ function select(list, start, end=undef) =
|
||||||
// list_range(n=4, s=[3,4], step=[2,3]); // Returns [[3,4], [5,7], [7,10], [9,13]]
|
// list_range(n=4, s=[3,4], step=[2,3]); // Returns [[3,4], [5,7], [7,10], [9,13]]
|
||||||
function list_range(n=undef, s=0, e=undef, step=undef) =
|
function list_range(n=undef, s=0, e=undef, step=undef) =
|
||||||
(n!=undef && e!=undef)? (
|
(n!=undef && e!=undef)? (
|
||||||
assert(n!=undef && e!=undef && step!=undef, "At most 2 of n, e, and step can be given.")
|
assert(is_undef(n) || is_undef(e) || is_undef(step), "At most 2 of n, e, and step can be given.")
|
||||||
[for (i=[0:1:n-1]) s+(e-s)*i/(n-1)]
|
[for (i=[0:1:n-1]) s+(e-s)*i/(n-1)]
|
||||||
) : let(step = default(step,1))
|
) : let(step = default(step,1))
|
||||||
(n!=undef)? [for (i=[0:1:n-1]) let(v=s+step*i) v] :
|
(n!=undef)? [for (i=[0:1:n-1]) let(v=s+step*i) v] :
|
||||||
|
|
|
@ -54,6 +54,7 @@ module test_list_range() {
|
||||||
assert(list_range(s=3, e=5) == [3,4,5]);
|
assert(list_range(s=3, e=5) == [3,4,5]);
|
||||||
assert(list_range(s=3, e=8, step=2) == [3,5,7]);
|
assert(list_range(s=3, e=8, step=2) == [3,5,7]);
|
||||||
assert(list_range(s=4, e=8, step=2) == [4,6,8]);
|
assert(list_range(s=4, e=8, step=2) == [4,6,8]);
|
||||||
|
assert(list_range(e=4, n=3) == [0,2,4]);
|
||||||
assert(list_range(n=4, s=[3,4], step=[2,3]) == [[3,4], [5,7], [7,10], [9,13]]);
|
assert(list_range(n=4, s=[3,4], step=[2,3]) == [[3,4], [5,7], [7,10], [9,13]]);
|
||||||
}
|
}
|
||||||
test_list_range();
|
test_list_range();
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,43];
|
BOSL_VERSION = [2,0,44];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue