alltom
03/01/2024, 10:11 PMvar clamp = function(num) {
return num > 2 ? 2 : num
}
clamp(sum(repeat(3, function() {
return flip()
})))
What's new this time? User-defined functions! There's one anonymous, single-use function at the top (the one that's passed to repeat()
), and a function named clamp
below that's written to be reused. Functions = Boxes. Lu took lines, but I think boxes are still available.
The writeup is here: http://alltom.com/pages/ppl-lab-notebook/005.html If you want to know the whys and the hows, it's for you. I love how the lab notebook / experiment writeup format gives me places to hang all the random things I'd like to write about. Design vicariously with me. 🙂
(Even if you don't have the time to read the writeup, I want you to know that I do not like how the clamp function's source code looks. I'm not done. But I decided a few entries back that I was going to dump all the LEGO bricks onto the floor where I could see them before I started picking the ones I wanted in my spaceship.)