1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import Text.Printf
import Linear.V3
--import Control.Lens
sp xa@(_:xs) = sp xs ++ [sum(xa)]
-- fo2 f xs =
--repeatlast xs = xs ++
-- sp sh = 0 ++ head sh ++
shelf_thickness = 0.5
shelf_width = 4
shelf_length = 16
shelfd = [shelf_thickness, shelf_width, shelf_length]
shelf_heights = [2,3,5,5]
sh = shelf_heights
--side_dims = [0.5,last sh,shelf_width]
--side_poss = [[0,0,0], [shelf_length + (side_dims[0] * 2), 0, 0]]
-- working algorithm doing the same as `scanl (+) 0 shelf_heights`
--acc [] = [0]
--acc xs = acc(init xs) ++ [sum xs]
shelf_y_poss = scanl (+) 0 shelf_heights
shelf_poss = [ [0,y,0] | y <- shelf_y_poss ]
shelf_height = sum shelf_heights
scad_place_board pos dim = "transform(" ++ show(pos) ++ ") { cube(" ++ show(dim) ++ ");}"
scad_place_shelf pos = scad_place_board pos shelfd
scad_place_shelves = map (scad_place_shelf) shelf_poss
--scad_place_sides = map (scad_place_board) [ [0, 0, 0],
--scad_place_shelf vpos = scad_place_board show([0, vpos, 0]) show(shelfd)
--gen_openscad = map (scad_place_piece
--accu [x] = x
--accu xs = sum(xs) ++ accu(tail xs)
-- OUTPUT: [0,5,8,10]
|