Lambda Function for Shaping
Learn to create a Lambda function for shaping sweets.
We'll cover the following
After we've mixed the ingredients in the previous steps of our state machine, we now have a sweets batch ready for shaping. The Shaping
step represents the process where our mixed ingredients are transformed into the actual shapes of sweets.
Implementation of the Lambda function
In our implementation, we're assuming that we have a machine capable of creating sweets in three shapes—Square
, Circle
, and Triangle
. When the shaping Lambda function is invoked, it will simulate this process by mapping over the batch of mixed sweets and randomly assigning one of the possible shapes to each sweet, and the same for the name.
After the shaping process, the Lambda function will return an array of shaped sweets, each containing its ingredient, quantity, and assigned shape and name.
Let's use the below IDE, with the opened shaping.ts
file.
Get hands-on with 1400+ tech skills courses.