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:
@ -1,6 +1,7 @@
|
||||
//! Functions implemented for language execution.
|
||||
|
||||
pub mod args;
|
||||
pub mod array;
|
||||
pub mod assert;
|
||||
pub mod chamfer;
|
||||
pub mod convert;
|
||||
@ -91,6 +92,7 @@ lazy_static! {
|
||||
Box::new(crate::std::patterns::PatternCircular2D),
|
||||
Box::new(crate::std::patterns::PatternCircular3D),
|
||||
Box::new(crate::std::patterns::PatternTransform),
|
||||
Box::new(crate::std::array::ArrayReduce),
|
||||
Box::new(crate::std::chamfer::Chamfer),
|
||||
Box::new(crate::std::fillet::Fillet),
|
||||
Box::new(crate::std::fillet::GetOppositeEdge),
|
||||
|
Reference in New Issue
Block a user