KCL stdlib reduce function (#3881)
Adds an `arrayReduce` function to KCL stdlib. Right now, it can only reduce SketchGroup values because my implementation of higher-order KCL functions sucks. But we will generalize it in the future to be able to reduce any type.
This simplifies sketching polygons, e.g.
```
fn decagon = (radius) => {
  let step = (1/10) * tau()
  let sketch = startSketchAt([
    (cos(0) * radius), 
    (sin(0) * radius),
  ])
  return arrayReduce([1..10], sketch, (i, sg) => {
      let x = cos(step * i) * radius
      let y = sin(step * i) * radius
      return lineTo([x, y], sg)
  })
}
```
Part of #3842
			
			
This commit is contained in:
		
							
								
								
									
										858
									
								
								docs/kcl/arrayReduce.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										858
									
								
								docs/kcl/arrayReduce.md
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -19,6 +19,7 @@ layout: manual
 | 
			
		||||
* [`angledLineToX`](kcl/angledLineToX)
 | 
			
		||||
* [`angledLineToY`](kcl/angledLineToY)
 | 
			
		||||
* [`arc`](kcl/arc)
 | 
			
		||||
* [`arrayReduce`](kcl/arrayReduce)
 | 
			
		||||
* [`asin`](kcl/asin)
 | 
			
		||||
* [`assert`](kcl/assert)
 | 
			
		||||
* [`assertEqual`](kcl/assertEqual)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										6670
									
								
								docs/kcl/std.json
									
									
									
									
									
								
							
							
						
						
									
										6670
									
								
								docs/kcl/std.json
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user