mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-04-13 19:31:56 +02:00
Changed list_range(s,e,n) to auto-set step to (e-s)/(n-1).
This commit is contained in:
parent
6dbff74f2b
commit
5133734cfd
@ -127,7 +127,7 @@ function select(list, start, end=undef) =
|
||||
// list_range(4); // Returns [0,1,2,3]
|
||||
// list_range(n=4, step=2); // Returns [0,2,4,6]
|
||||
// list_range(n=4, s=3, step=3); // Returns [3,6,9,12]
|
||||
// list_range(n=4, s=3, e=9, step=3); // Returns [3,6,9]
|
||||
// list_range(n=5, s=0, e=10); // Returns [0, 2.5, 5, 7.5, 10]
|
||||
// list_range(e=3); // Returns [0,1,2,3]
|
||||
// list_range(e=6, step=2); // Returns [0,2,4,6]
|
||||
// list_range(s=3, e=5); // Returns [3,4,5]
|
||||
@ -135,7 +135,7 @@ function select(list, start, end=undef) =
|
||||
// list_range(s=4, e=8, step=2); // Returns [4,6,8]
|
||||
// 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=1) =
|
||||
(n!=undef && e!=undef)? [for (i=[0:1:n-1]) let(v=s+step*i) if (v<=e) v] :
|
||||
(n!=undef && e!=undef)? [for (i=[0:1:n-1]) s+(e-s)*i/(n-1)] :
|
||||
(n!=undef)? [for (i=[0:1:n-1]) let(v=s+step*i) v] :
|
||||
(e!=undef)? [for (v=[s:step:e]) v] :
|
||||
assert(e!=undef||n!=undef, "Must supply one of `n` or `e`.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user