Bed David
This commit is contained in:
parent
3786b1ee9e
commit
850333ea1b
13 changed files with 1215 additions and 5 deletions
17
Bed_David/functions.scad
Normal file
17
Bed_David/functions.scad
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// input : list of numbers
|
||||
// output : sorted list of numbers
|
||||
function quicksort(arr) = !(len(arr)>0) ? [] : let(
|
||||
pivot = arr[floor(len(arr)/2)],
|
||||
lesser = [ for (y = arr) if (y < pivot) y ],
|
||||
equal = [ for (y = arr) if (y == pivot) y ],
|
||||
greater = [ for (y = arr) if (y > pivot) y ]
|
||||
) concat(
|
||||
quicksort(lesser), equal, quicksort(greater)
|
||||
);
|
||||
|
||||
module cuben(name, size){
|
||||
cube(size=size, center=false);
|
||||
// sizes should be ordered biggest to smallest
|
||||
size_sorted=quicksort(size);
|
||||
echo(str("#### ", name, ": " , size_sorted[2], "x", size_sorted[1], "x", size_sorted[0]));
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue