3 ms·
I like the example about the distributive law. But for the associative law, one could also simply write: add(x, add(y, z)) == add(x, y, z)
by leethargo 7y ago
I like the example about the distributive law. But for the associative law, one could also simply write:
add(x, add(y, z)) == add(x, y, z)
- abjKT26nO8 7y agoNo. That assumes that "add" is left-associative, i.e. it expands to add((add(x, y), z)). It's not obvious.
- leethargo 7y agoOK, but for operators that are both left- and right-associative, this notation (variable number of arguments) is already used, e.g. in LISP, right?
- abjKT26nO8 7y agoBoth... at the same time? I.e. they are associative? If only one at a time, then perhaps there is. But TBH I can't think of an example from the top of my head right now.
- leethargo 7y agoYes, I meant (fully) associative.
- abjKT26nO8 7y agoIn this case it's justified, because there is no ambiguity. Just as a mathematician would write using traditional notation without parentheses. At the courses I attended in group theory, module theory etc. we were always required to prove that things are associative before dropping parentheses. Lisp notation just requires less characters (the '+' isn't repeated), but the convention is the same.