(eql (* x (+ y z)) (+ (* x y) (* x z)))
I wonder if its famed sense of enlightenment is partly just overcoming the mental hurdle of it's syntax.Edit: typo fix, had x/z mixed up
(eql (* x (+ y z)) (+ (* x y) (* x z)))
I wonder if its famed sense of enlightenment is partly just overcoming the mental hurdle of it's syntax.Edit: typo fix, had x/z mixed up
(= (* x (+ y z))
(+ (* x z) (* y z)))
Or: (= (* x (+ y z))
(+ (* x z)
(* y z)))
Or: (= (* x
(+ y z))
(+ (* x z)
(* y z)))
Or: (= (+ (* x z)
(* y z))
(* x (+ y z)))
Or: (= (+ (* x z)
(* y z))
(* (+ y z) x))
Or: (= (+ (* x z)
(* y z))
(* (+ y z)
x))
I think the last one makes the relationships quite clear.Writing legible equations is an art form, as is writing sexps.
Edit: If you think lisp is ugly, compare with regexps. For bonus points, explore writing regexps with lisp, e.g. with Emacs's `rx` macro. I think you won't find a more easily maintainable way to write them.
Large teams don't want artists, they want replaceable parts.
If it's about formatting, given that this is what this thread is about, you can use code formatter for lisp languages exactly like for any other language, in fact they are even easier to write for lisp because of the consistency of S expressions.
If you are talking about macro, then you're in the same boat as other languages that have macros, C, Rust, ect... And remember that the first rule of macros is to not use macros, except for when you absolutely have to, and in those cases it is the most elegant solution. If you have devs inventing DSLs for everything, then lisp isn't your problem.
Thankfully, Michelangelo and Leonardo were not in large teams.
Which do you aspire to be: a cog or an artist?
x * (y + z) = x * z + y * z
x * (y + z) =
x * z + y * z
x * (y + z)
= x * z + y * z
x *
(y +
z)
=
x *
z
+
y *
z
etc.This is true for a lot of "frameworks" and especially true for modern fontend web frameworks (which have a compile/build step).
xz + yz = x(y + z)
when using operators?
That seems wrong.
(= (* x (+ y z))
(+ (* x z) (* y z)))
As x*(y + z) = x*z + y*z
e.g. (+ y z) means you add y and z with highest priority. (x * (y + z)) eql ((x * z) + (y * z))
Or: (y + z * x) eql (x * z + (y * z))
With different precedence: x * (y + z) eql x * z + y * z
But now you have to remember precedences and mentally regroup the expression. (eqn x * (y + z) = x * z + y * z)
where you write and test an `eqn` macro that rewrites everything in the correct syntax. x * (y + z) = x * z + y * z reduces to
($= x * (y + z) = x * z + y * z)
Specifically its more complex only in that the entire expression is wrapped in ($= )In order to give x y and z values to run it simply wrap it in a let and give them values.
(let [x 1 y 2 z 1]
($= x * (y + z) = x * z + y * z))
alternatively wrap it in a function (defn testme [x y z]
($= x * (y + z) = x * z + y * z))