26 ms·
I think the very same is happening in scheme. Scheme's functions naturally works on lists: +, * , and, or. Applying it on empty lists gives us: > (and) #t
by rmrfchik 7y ago
I think the very same is happening in scheme.
Scheme's functions naturally works on lists: +, * , and, or.
Applying it on empty lists gives us:
> (and)
#t
> (or)
#f
> (+)
0
And most surprising (although it's very convenient on second thought):
> (* )
1
Thus multiplication on empty list gives 1.
- chewbacha 7y agoI believe that’s likely acting as a reduction with an initial value. When you sum you start with 0 and when you multiply you start with 1. These provide identity functions for the first addition and multiplication. 1 * x = x 0 + x = x