5 ms·
In addition the variadic prefix-notation means the operators are not limited to being binary: 3*x*y*z+w becomes: (+ (* 3 x y z) w)
by aidenn0 6y ago
In addition the variadic prefix-notation means the operators are not limited to being binary:
3*x*y*z+w
becomes:
(+ (* 3 x y z) w)
- User23 6y agoAlso, pleasantly the 0-ary invocation is the identity so (+) is 0 and (*) is 1.
- hansvm 6y agoDoes lisp have native bigints, or would something like (+ MAX_INT MAX_INT MIN_INT) still suffer from operator precedence issues?
- kazinator 6y agoCommon Lisp's integers are transparently multi-precision. There is no need to work with a separate type, or to use special syntax for writing bignum tokens in source code. Bignum support first appeared in the MacLisp dialect in 1970 or 1970, one of the main predecessor dialects of Common Lisp. According to Gabriel and Steele's Evolution of Lisp paper, "bignums—arbitrary precision integer arithmetic—were added [to MacLisp] in 1970 or 1971 to meet the needs of Macsyma users".
- aidenn0 6y agoI dont' know about other lisps, but both common-lisp and scheme have native bignums and fixnums are promoted to bignums automatically.
- spicybright 6y agoAt least you could write a simple macro to do left to right evaluation with standard operators to get the same effect if you wanted.
- ganafagol 6y agoIn addition to requiring remembering the precedence of + versus * this requires you to remember order of evaluation. Is it (ab)c or a(bc)? And no, with certain types those are not necessarily the same. Floats, for example.
- aidenn0 6y ago1. It doesn't require you to remember precedence, since there is no ambiguity 2. It doesn't require you to remember order of evaluation because the order is unspecified (* x y z) is defined to be "The product of x, y, and z" with no requirement on the order of evaluation. If you need a well-defined order of evaluation then you can do that explicitly: (* x (* y z))